1 package org.jzonic.jlo; 2 3 import org.jzonic.jlo.processor.LogProcessor; 4 import org.jzonic.jlo.processor.LogProcessorFactory; 5 11 public class Channel { 12 13 private static final LogProcessor processor = LogProcessorFactory.getLogProcessor(); 14 private LogGenerator lg; 15 private String name; 16 private boolean on; 17 18 19 26 public Channel(String name, LogGenerator lg) { 27 this(name, lg, false); 28 } 29 30 31 39 public Channel(String name, LogGenerator lg, boolean on) { 40 this.name = name; 41 this.lg = lg; 42 this.on = on; 43 } 44 45 46 51 public void log(String msg) { 52 if (on) { 53 log(msg, null); 54 } 55 } 56 57 58 64 public void log(String msg, Throwable thrown) { 65 if (on) { 66 LogRecord lr = new LogRecord(msg); 67 if (thrown != null) { 68 lr.setThrown(thrown); 69 } 70 log(lr); 71 } 72 } 73 74 75 80 public void log(LogRecord lr) { 81 processor.processEvent(lg, lr); 82 } 83 84 85 public LogGenerator getLogGenerator() { 86 return lg; 87 } 88 89 public String getChannelName() { 90 return name; 91 } 92 97 public boolean isOn() { 98 return on; 99 } 100 101 } 102 | Popular Tags |