Mercurial Hosting > luan
view src/luan/modules/logging/LuanLogger.java @ 1334:c88b486a9511
make some Luan methods static
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 12 Feb 2019 22:53:57 -0700 |
parents | 25746915a241 |
children | 8b61c8c4e07a |
line wrap: on
line source
package luan.modules.logging; import org.slf4j.Logger; import org.slf4j.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(); } }