Mercurial Hosting > luan
view src/luan/modules/logging/LuanLogger.java @ 1364:45363886f256
add url methods
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Wed, 29 May 2019 19:03:25 -0600 |
parents | 8b61c8c4e07a |
children | 002152af497a |
line wrap: on
line source
package luan.modules.logging; import luan.lib.logging.Logger; import luan.lib.logging.LoggerFactory; import luan.Luan; import luan.LuanException; public final class LuanLogger { private final Logger logger; public LuanLogger(Luan luan,String name) { this.logger = getLogger(luan,name); } public void error(Object obj) throws LuanException { logger.error( Luan.luanToString(obj) ); } public void warn(Object obj) throws LuanException { logger.warn( Luan.luanToString(obj) ); } public void info(Object obj) throws LuanException { logger.info( Luan.luanToString(obj) ); } public void debug(Object obj) throws LuanException { logger.debug( Luan.luanToString(obj) ); } private static ThreadLocal<Luan> tl = new ThreadLocal<Luan>(); public static Logger getLogger(Luan luan,String name) { try { luan.require("luan:logging/Logging.luan"); // ensure initialization } catch(LuanException e) { throw new RuntimeException(e); } tl.set(luan); try { return LoggerFactory.getLogger(name); } finally { tl.remove(); } } public static Luan luan() { return tl.get(); } }