# HG changeset patch # User cli # Date 1272732717 -7200 # Node ID 60c237bb677afa35e57bed26541cdc7173aa5af0 # Parent 15d14b110240b2166422d0948e605097972dd747 Refactor logging to fix NullPointerException. diff -r 15d14b110240 -r 60c237bb677a org/sonews/util/Log.java --- a/org/sonews/util/Log.java Sat May 01 14:27:30 2010 +0200 +++ b/org/sonews/util/Log.java Sat May 01 18:51:57 2010 +0200 @@ -30,33 +30,28 @@ * @author Christian Lins * @since sonews/0.5.0 */ -public class Log +public class Log extends Logger { - public static final String MAIN = "main"; + private static Log instance = new Log(); - static + private Log() { - Logger mainLogger = Logger.getLogger(MAIN); + super("org.sonews", null); + StreamHandler handler = new StreamHandler(System.out, new SimpleFormatter()); Level level = Level.parse(Config.inst().get(Config.LOGLEVEL, "INFO")); handler.setLevel(level); - mainLogger.addHandler(handler); - mainLogger.setLevel(level); - LogManager.getLogManager().addLogger(mainLogger); + addHandler(handler); + setLevel(level); + LogManager.getLogManager().addLogger(this); } public static Logger get() { - return get(MAIN); - } - - public static Logger get(String name) - { Level level = Level.parse(Config.inst().get(Config.LOGLEVEL, "INFO")); - Logger logger = LogManager.getLogManager().getLogger(name); - logger.setLevel(level); - return logger; + instance.setLevel(level); + return instance; } }