/******************************************************************************* *******************************************************************************/ package at.gv.egiz.eaaf.core.impl.gui.velocity; import org.apache.velocity.app.Velocity; import org.apache.velocity.runtime.RuntimeServices; import org.apache.velocity.runtime.log.LogChute; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class VelocityLogAdapter implements LogChute { private static final Logger log = LoggerFactory.getLogger(VelocityLogAdapter.class); public VelocityLogAdapter() { try { /* * register this class as a logger with the Velocity singleton * (NOTE: this would not work for the non-singleton method.) */ Velocity.setProperty(Velocity.RUNTIME_LOG_LOGSYSTEM, this ); Velocity.init(); } catch (Exception e) { log.error("Failed to register Velocity logger"); } } public void init(RuntimeServices arg0) throws Exception { } public boolean isLevelEnabled(int arg0) { switch(arg0) { case LogChute.DEBUG_ID: return log.isDebugEnabled(); case LogChute.TRACE_ID: return log.isTraceEnabled(); default: return true; } } public void log(int arg0, String arg1) { switch(arg0) { case LogChute.DEBUG_ID: log.debug(arg1); break; case LogChute.TRACE_ID: log.trace(arg1); break; case LogChute.INFO_ID: log.info(arg1); break; case LogChute.WARN_ID: log.warn(arg1); break; case LogChute.ERROR_ID: default: log.error(arg1); break; } } public void log(int arg0, String arg1, Throwable arg2) { switch(arg0) { case LogChute.DEBUG_ID: case LogChute.TRACE_ID: case LogChute.INFO_ID: case LogChute.WARN_ID: log.warn(arg1, arg2); break; case LogChute.ERROR_ID: default: log.error(arg1, arg2); break; } } }