01: package org.jzonic.jlo;
02:
03: import org.jzonic.jlo.processor.LogProcessor;
04: import org.jzonic.jlo.processor.LogProcessorFactory;
05:
06: /**
07: * Description of the Class
08: *
09: *@author andreas
10: *@created 9. März 2002
11: */
12: public class Channel {
13:
14: private static final LogProcessor processor = LogProcessorFactory
15: .getLogProcessor();
16: private LogGenerator lg;
17: private String name;
18: private boolean on;
19:
20: /**
21: * Constructor for the Channel object
22: *
23: *@param name Description of the Parameter
24: *@param handler Description of the Parameter
25: *@param formatter Description of the Parameter
26: */
27: public Channel(String name, LogGenerator lg) {
28: this (name, lg, false);
29: }
30:
31: /**
32: * Constructor for the Channel object
33: *
34: *@param name Description of the Parameter
35: *@param handler Description of the Parameter
36: *@param formatter Description of the Parameter
37: *@param on Description of the Parameter
38: */
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: * Description of the Method
47: *
48: *@param msg Description of the Parameter
49: */
50: public void log(String msg) {
51: if (on) {
52: log(msg, null);
53: }
54: }
55:
56: /**
57: * Description of the Method
58: *
59: *@param msg Description of the Parameter
60: *@param thrown Description of the Parameter
61: */
62: public void log(String msg, Throwable thrown) {
63: if (on) {
64: LogRecord lr = new LogRecord(msg);
65: if (thrown != null) {
66: lr.setThrown(thrown);
67: }
68: log(lr);
69: }
70: }
71:
72: /**
73: * Description of the Method
74: *
75: *@param lr Description of the Parameter
76: */
77: public void log(LogRecord lr) {
78: processor.processEvent(lg, lr);
79: }
80:
81: public LogGenerator getLogGenerator() {
82: return lg;
83: }
84:
85: public String getChannelName() {
86: return name;
87: }
88:
89: /**
90: * Gets the on attribute of the Channel object
91: *
92: *@return The on value
93: */
94: public boolean isOn() {
95: return on;
96: }
97:
98: }
|