From: David ‘Bombe’ Roden Date: Fri, 9 May 2008 19:32:17 +0000 (+0000) Subject: fix log handler level X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=439bd54002fcdfa9f88d7f21236d4d8b3fadd6b0;p=jSite2.git fix log handler level add method to create logger in the custom hierarchy git-svn-id: http://trooper/svn/projects/jSite/trunk@802 c3eda9e8-030b-0410-8277-bc7414b0a119 --- diff --git a/src/net/pterodactylus/util/logging/Logging.java b/src/net/pterodactylus/util/logging/Logging.java index 443c05d..66ca181 100644 --- a/src/net/pterodactylus/util/logging/Logging.java +++ b/src/net/pterodactylus/util/logging/Logging.java @@ -38,6 +38,13 @@ public class Logging { /** The log handler. */ private static final LogHandler logHandler = new LogHandler(); + static { + logHandler.setLevel(Level.ALL); + } + + /** The root name of the hierarchy. */ + private static String hierarchyRootName; + /** * Adds a listener to the log handler. * @@ -60,12 +67,28 @@ public class Logging { /** * Sets up logging and installs the log handler. + * + * @param hierarchyName + * The name of the hierarchy root logger */ - public static void setup() { - Logger rootLogger = Logger.getAnonymousLogger().getParent(); + public static void setup(String hierarchyName) { + hierarchyRootName = hierarchyName; + Logger rootLogger = Logger.getLogger(hierarchyName); rootLogger.addHandler(logHandler); + rootLogger.setUseParentHandlers(false); rootLogger.setLevel(Level.ALL); - logHandler.setLevel(Level.INFO); + } + + /** + * Returns a named logger from the jSite hierarchy. + * + * @param name + * The name of the logger + * @return The logger + */ + public static Logger getLogger(String name) { + Logger logger = Logger.getLogger(hierarchyRootName + "." + name); + return logger; } /** @@ -82,6 +105,7 @@ public class Logging { * Package-private constructor. */ LogHandler() { + /* do nothing. */ } /** The list of the listeners. */ @@ -132,6 +156,7 @@ public class Logging { */ @Override public void close() throws SecurityException { + /* do nothing. */ } /** @@ -139,6 +164,7 @@ public class Logging { */ @Override public void flush() { + /* do nothing. */ } /**