Mercurial Hosting > luan
changeset 1336:7483108154bb
minor logging
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 14 Feb 2019 05:22:22 -0700 |
parents | e0cf0d108a77 |
children | 8b61c8c4e07a |
files | src/luan/host/WebHandler.java src/luan/modules/http/LuanDomainHandler.java src/luan/modules/logging/Log4j.java |
diffstat | 3 files changed, 15 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
diff -r e0cf0d108a77 -r 7483108154bb src/luan/host/WebHandler.java --- a/src/luan/host/WebHandler.java Thu Feb 14 03:10:45 2019 -0700 +++ b/src/luan/host/WebHandler.java Thu Feb 14 05:22:22 2019 -0700 @@ -32,11 +32,7 @@ new File(logDir).mkdirs(); Luan luan = new Luan(); - try { - Log4j.newLoggerRepository(luan); - } catch(LuanException e) { - throw new RuntimeException(e); - } + Log4j.newLoggerRepository(luan); initLuan(luan,dirStr,domain,true); return new LuanHandler(luan); }
diff -r e0cf0d108a77 -r 7483108154bb src/luan/modules/http/LuanDomainHandler.java --- a/src/luan/modules/http/LuanDomainHandler.java Thu Feb 14 03:10:45 2019 -0700 +++ b/src/luan/modules/http/LuanDomainHandler.java Thu Feb 14 05:22:22 2019 -0700 @@ -26,15 +26,15 @@ return new LuanHandler(luan); } - protected void newLoggerRepository(Luan luan) throws LuanException { + protected void newLoggerRepository(Luan luan) { Log4j.newLoggerRepository(luan); } protected Luan newLuan(String domain) { LuanCloner cloner = new LuanCloner(LuanCloner.Type.COMPLETE); Luan luan = (Luan)cloner.clone(luanInit); + newLoggerRepository(luan); try { - newLoggerRepository(luan); LuanTable Http = (LuanTable)luan.require("luan:http/Http.luan"); Http.put( "domain", domain ); } catch(LuanException e) {
diff -r e0cf0d108a77 -r 7483108154bb src/luan/modules/logging/Log4j.java --- a/src/luan/modules/logging/Log4j.java Thu Feb 14 03:10:45 2019 -0700 +++ b/src/luan/modules/logging/Log4j.java Thu Feb 14 05:22:22 2019 -0700 @@ -1,9 +1,11 @@ package luan.modules.logging; +import java.util.Enumeration; import org.apache.log4j.Logger; import org.apache.log4j.LogManager; import org.apache.log4j.Hierarchy; import org.apache.log4j.Level; +import org.apache.log4j.Appender; import org.apache.log4j.spi.LoggerRepository; import org.apache.log4j.spi.RootLogger; import org.apache.log4j.spi.RepositorySelector; @@ -13,17 +15,20 @@ public final class Log4j { - private static String KEY = "Logger.Repository"; + private static final String KEY = "Logger.Repository"; + private static final LoggerRepository defaultLoggerRepository = LogManager.getLoggerRepository(); - public static void newLoggerRepository(Luan luan) throws LuanException { - LoggerRepository lr = new Hierarchy(new RootLogger(Level.DEBUG)); + public static void newLoggerRepository(Luan luan) { + Logger oldLogger = defaultLoggerRepository.getRootLogger(); + Logger newLogger = new RootLogger(Level.DEBUG); + LoggerRepository lr = new Hierarchy(newLogger); + for( Enumeration en = oldLogger.getAllAppenders(); en.hasMoreElements(); ) { + Appender appender = (Appender)en.nextElement(); + newLogger.addAppender(appender); + } luan.registry().put(KEY,lr); - LuanTable module = (LuanTable)luan.require("luan:logging/Log4j.luan"); - module.fn("init_root").call(); } - private static final LoggerRepository defaultLoggerRepository = LogManager.getLoggerRepository(); - private static LoggerRepository getLoggerRepository(Luan luan) { LoggerRepository lr = (LoggerRepository)luan.registry().get(KEY); return lr != null ? lr : defaultLoggerRepository;