1 4 5 package org.objectweb.util.monolog.wrapper.velocity; 6 7 import org.apache.velocity.runtime.RuntimeServices; 8 import org.apache.velocity.runtime.log.LogSystem; 9 import org.objectweb.util.monolog.api.BasicLevel; 10 import org.objectweb.util.monolog.api.Logger; 11 12 19 public class VelocityLogger implements LogSystem { 20 21 private Logger log = null; 22 23 public VelocityLogger(Logger l) 24 throws UnsupportedOperationException { 25 if (l == null) { 26 throw new UnsupportedOperationException ("Null logger unsupported"); 27 } 28 this.log = l; 29 } 30 31 public void setLog(Logger l) { 32 if (l == null) { 33 throw new UnsupportedOperationException ("Null logger unsupported"); 34 } 35 this.log = l; 36 } 37 38 public Logger getLog() { 39 return log; 40 } 41 42 45 48 public void init(RuntimeServices services) throws Exception { 49 if (log == null) { 50 throw new UnsupportedOperationException ("Null logger unsupported"); 51 } 52 } 53 54 public void logVelocityMessage(int i, String s) { 55 if (i == LogSystem.WARN_ID) { 56 log.log(BasicLevel.WARN, s); 57 } 58 else if (i == LogSystem.ERROR_ID) { 59 log.log(BasicLevel.ERROR, s); 60 } 61 else if (i == LogSystem.INFO_ID) { 62 log.log(BasicLevel.INFO, s); 63 } 64 else if (i == LogSystem.DEBUG_ID) { 65 log.log(BasicLevel.DEBUG, s); 66 } 67 } 68 } 69 | Popular Tags |