KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jzonic > jlo > Channel


1 package org.jzonic.jlo;
2
3 import org.jzonic.jlo.processor.LogProcessor;
4 import org.jzonic.jlo.processor.LogProcessorFactory;
5 /**
6  * Description of the Class
7  *
8  *@author andreas
9  *@created 9. März 2002
10  */

11 public class Channel {
12     
13     private static final LogProcessor processor = LogProcessorFactory.getLogProcessor();
14     private LogGenerator lg;
15     private String JavaDoc name;
16     private boolean on;
17     
18     
19     /**
20      * Constructor for the Channel object
21      *
22      *@param name Description of the Parameter
23      *@param handler Description of the Parameter
24      *@param formatter Description of the Parameter
25      */

26     public Channel(String JavaDoc name, LogGenerator lg) {
27         this(name, lg, false);
28     }
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 JavaDoc name, LogGenerator lg, boolean on) {
40         this.name = name;
41         this.lg = lg;
42         this.on = on;
43     }
44     
45     
46     /**
47      * Description of the Method
48      *
49      *@param msg Description of the Parameter
50      */

51     public void log(String JavaDoc msg) {
52         if (on) {
53             log(msg, null);
54         }
55     }
56     
57     
58     /**
59      * Description of the Method
60      *
61      *@param msg Description of the Parameter
62      *@param thrown Description of the Parameter
63      */

64     public void log(String JavaDoc msg, Throwable JavaDoc 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     /**
76      * Description of the Method
77      *
78      *@param lr Description of the Parameter
79      */

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 JavaDoc getChannelName() {
90         return name;
91     }
92     /**
93      * Gets the on attribute of the Channel object
94      *
95      *@return The on value
96      */

97     public boolean isOn() {
98         return on;
99     }
100     
101 }
102
Popular Tags