9
9
* <strong>Internal</strong> exception logging utility for the cffu library.
10
10
* <p>
11
11
* By default, uncaught exceptions are logged with their complete stack traces. The logging behavior can be configured
12
- * through the system property {@code cffu.uncaught. exception.log.format} with the following values:
12
+ * through the system property {@code cffu.exception.log.format} with the following values:
13
13
* <ul>
14
14
* <li>{@code full}: Log the complete exception stack trace (default)</li>
15
15
* <li>{@code short}: Log only the exception message</li>
18
18
* <p>
19
19
* Configure the logging format by either:
20
20
* <ul>
21
- * <li>Setting the JVM argument {@code -Dcffu.uncaught. exception.log.format=<value>} at startup</li>
22
- * <li>Calling {@code System.setProperty("cffu.uncaught. exception.log.format", "<value>")} programmatically</li>
21
+ * <li>Setting the JVM argument {@code -Dcffu.exception.log.format=<value>} at startup</li>
22
+ * <li>Calling {@code System.setProperty("cffu.exception.log.format", "<value>")} programmatically</li>
23
23
* </ul>
24
24
*
25
25
* @author HuHao (995483610 at qq dot com)
@@ -33,22 +33,25 @@ public final class ExceptionLogger {
33
33
private static final LoggerAdapter logger = getLogger ();
34
34
35
35
@ SuppressWarnings ("StatementWithEmptyBody" )
36
- public static void logUncaughtException (String where , Throwable ex ) {
36
+ public static void logException (String msg , Throwable ex ) {
37
37
final String fullFormat = "full" ;
38
38
final String shortFormat = "short" ;
39
39
final String noneFormat = "none" ;
40
40
41
- final String format = System .getProperty ("cffu.uncaught.exception.log.format" , fullFormat );
42
- final String msgHead = "Uncaught exception occurred at " ;
41
+ final String format = System .getProperty ("cffu.exception.log.format" , fullFormat );
43
42
if (noneFormat .equalsIgnoreCase (format )) {
44
43
// pass silently when explicitly silenced.
45
44
} else if (shortFormat .equalsIgnoreCase (format )) {
46
- logger .error (msgHead + where + ", " + ex , null );
45
+ logger .error (msg + ", " + ex , null );
47
46
} else {
48
- logger .error (msgHead + where , ex );
47
+ logger .error (msg , ex );
49
48
}
50
49
}
51
50
51
+ public static void logUncaughtException (String where , Throwable ex ) {
52
+ logException ("Uncaught exception occurred at " + where , ex );
53
+ }
54
+
52
55
/**
53
56
* Returns a logger adapter that uses {@code SLF4J} if available, otherwise uses {@link java.util.logging}.
54
57
*/
0 commit comments