diff --git a/classpath/java/util/logging/Logger.java b/classpath/java/util/logging/Logger.java index 5a1e7ee055..6fb968dd83 100644 --- a/classpath/java/util/logging/Logger.java +++ b/classpath/java/util/logging/Logger.java @@ -16,15 +16,23 @@ import java.util.List; public class Logger { private final String name; - private int levelValue = Level.INFO.intValue(); + private Level levelValue = null; private static final ArrayList handlers; + private static Logger rootLogger; + private Logger parent; + static { + rootLogger = new Logger(""); + rootLogger.setLevel(Level.INFO); handlers = new ArrayList(); handlers.add(new DefaultHandler()); } public static Logger getLogger(String name) { - return new Logger(name); + if (name.equals("")) return rootLogger; + Logger logger = new Logger(name); + logger.parent = rootLogger; + return logger; } private Logger(String name) { @@ -43,6 +51,10 @@ public class Logger { handlers.remove(handler); } + public Logger getParent() { + return parent; + } + public void fine(String message) { log(Level.FINE, Method.getCaller(), message, null); } @@ -81,12 +93,26 @@ public class Logger { } publish(new LogRecord(name, sourceMethod, level, msg, thrown)); } - + + public Level getLevel() { + return levelValue; + } + + private Level getEffectiveLevel() { + Logger logger = this; + + while (logger.levelValue == null) { + logger = logger.getParent(); + } + return logger.getLevel(); + } + private void log(Level level, Method caller, String message, Throwable exception) { - if (level.intValue()= levelValue; + return level.intValue() >= levelValue.intValue(); } private static class DefaultHandler extends Handler {