MCPcopy Index your code
hub / github.com/apache/tomcat / DirectJDKLog

Class DirectJDKLog

java/org/apache/juli/logging/DirectJDKLog.java:28–178  ·  view source on GitHub ↗

Hard-coded java.util.logging commons-logging implementation.

Source from the content-addressed store, hash-verified

26 * Hard-coded java.util.logging commons-logging implementation.
27 */
28class DirectJDKLog implements Log {
29 // no reason to hide this - but good reasons to not hide
30 public final Logger logger;
31
32 // Alternate config reader and console format
33 private static final String SIMPLE_FMT = "java.util.logging.SimpleFormatter";
34 private static final String FORMATTER = "org.apache.juli.formatter";
35
36 static {
37 if (System.getProperty("java.util.logging.config.class") == null &&
38 System.getProperty("java.util.logging.config.file") == null) {
39 // default configuration - it sucks. Let's override at least the
40 // formatter for the console
41 try {
42 Formatter fmt = (Formatter) Class.forName(System.getProperty(FORMATTER, SIMPLE_FMT)).getConstructor()
43 .newInstance();
44 // it is also possible that the user modified jre/lib/logging.properties -
45 // but that's really stupid in most cases
46 Logger root = Logger.getLogger("");
47 for (Handler handler : root.getHandlers()) {
48 // I only care about console - that's what's used in default config anyway
49 if (handler instanceof ConsoleHandler) {
50 handler.setFormatter(fmt);
51 }
52 }
53 } catch (Throwable t) {
54 // maybe it wasn't included - the ugly default will be used.
55 }
56
57 }
58 }
59
60 DirectJDKLog(String name) {
61 logger = Logger.getLogger(name);
62 }
63
64 @Override
65 public final boolean isErrorEnabled() {
66 return logger.isLoggable(Level.SEVERE);
67 }
68
69 @Override
70 public final boolean isWarnEnabled() {
71 return logger.isLoggable(Level.WARNING);
72 }
73
74 @Override
75 public final boolean isInfoEnabled() {
76 return logger.isLoggable(Level.INFO);
77 }
78
79 @Override
80 public final boolean isDebugEnabled() {
81 return logger.isLoggable(Level.FINE);
82 }
83
84 @Override
85 public final boolean isFatalEnabled() {

Callers

nothing calls this directly

Calls 6

forNameMethod · 0.80
getHandlersMethod · 0.80
getPropertyMethod · 0.65
newInstanceMethod · 0.65
getLoggerMethod · 0.65
getConstructorMethod · 0.45

Tested by

no test coverage detected