KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > protomatter > syslog > commons > SyslogChannelLog


1 package com.protomatter.syslog.commons;
2
3 /**
4  * {{{ The Protomatter Software License, Version 1.0
5  * derived from The Apache Software License, Version 1.1
6  *
7  * Copyright (c) 1998-2002 Nate Sammons. All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  *
13  * 1. Redistributions of source code must retain the above copyright
14  * notice, this list of conditions and the following disclaimer.
15  *
16  * 2. Redistributions in binary form must reproduce the above copyright
17  * notice, this list of conditions and the following disclaimer in
18  * the documentation and/or other materials provided with the
19  * distribution.
20  *
21  * 3. The end-user documentation included with the redistribution,
22  * if any, must include the following acknowledgment:
23  * "This product includes software developed for the
24  * Protomatter Software Project
25  * (http://protomatter.sourceforge.net/)."
26  * Alternately, this acknowledgment may appear in the software itself,
27  * if and wherever such third-party acknowledgments normally appear.
28  *
29  * 4. The names "Protomatter" and "Protomatter Software Project" must
30  * not be used to endorse or promote products derived from this
31  * software without prior written permission. For written
32  * permission, please contact support@protomatter.com.
33  *
34  * 5. Products derived from this software may not be called "Protomatter",
35  * nor may "Protomatter" appear in their name, without prior written
36  * permission of the Protomatter Software Project
37  * (support@protomatter.com).
38  *
39  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
40  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
41  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
42  * DISCLAIMED. IN NO EVENT SHALL THE PROTOMATTER SOFTWARE PROJECT OR
43  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
45  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
46  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
47  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
48  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
49  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
50  * SUCH DAMAGE. }}}
51  */

52
53 import org.apache.commons.logging.*;
54 import com.protomatter.syslog.*;
55 import com.protomatter.util.*;
56
57 /**
58  * An implementation of the <tt>org.apache.commons.logging.Log</tt> interface.
59  */

60 public class SyslogChannelLog
61 implements Log
62 {
63     /**
64      * A <tt>Debug</tt> instance with the same name as this object.
65      */

66     protected Debug debug = null;
67
68     /**
69      * The name of this <tt>Log</tt> instance.
70      */

71     protected String JavaDoc name = null;
72
73     /**
74      * Create a new log adapter with the given name.
75      */

76     public SyslogChannelLog(String JavaDoc name)
77     {
78         super();
79
80         this.name = name;
81         this.debug = Debug.forName(name);
82     }
83
84     /**
85      * Calls <tt>debug()</tt> on the <tt>Debug</tt> instance
86      * associated with this class.
87      *
88      * @see com.protomatter.util.Debug
89      */

90     public boolean isDebugEnabled()
91     {
92         return debug.debug();
93     }
94
95     /**
96      * Always returns <tt>true</tt>.
97      */

98     public boolean isErrorEnabled()
99     {
100         return true;
101     }
102
103     /**
104      * Always returns <tt>true</tt>.
105      */

106     public boolean isFatalEnabled()
107     {
108         return true;
109     }
110
111     /**
112      * Calls <tt>info()</tt> on the <tt>Debug</tt> instance
113      * associated with this class.
114      */

115     public boolean isInfoEnabled()
116     {
117         return debug.info();
118     }
119
120     /**
121      * Calls <tt>trace()</tt> on the <tt>Debug</tt> instance
122      * associated with this class.
123      *
124      * @see com.protomatter.util.Debug
125      */

126     public boolean isTraceEnabled()
127     {
128         return debug.trace();
129     }
130
131     /**
132      * Always returns <tt>true</tt>.
133      */

134     public boolean isWarnEnabled()
135     {
136         return true;
137     }
138
139
140     /**
141      *
142      */

143     public void trace(Object JavaDoc message)
144     {
145         Syslog.log(Syslog.getLocalHostName(),
146             this, this.name, message, null, Syslog.DEBUG,
147             Thread.currentThread(), Thread.currentThread().getName(),
148             System.currentTimeMillis(), 1);
149     }
150
151     /**
152      *
153      */

154     public void trace(Object JavaDoc message, Throwable JavaDoc t)
155     {
156         Syslog.log(Syslog.getLocalHostName(),
157             this, this.name, message, t, Syslog.DEBUG,
158             Thread.currentThread(), Thread.currentThread().getName(),
159             System.currentTimeMillis(), 1);
160     }
161
162     /**
163      *
164      */

165     public void debug(Object JavaDoc message)
166     {
167         Syslog.log(Syslog.getLocalHostName(),
168             this, this.name, message, null, Syslog.DEBUG,
169             Thread.currentThread(), Thread.currentThread().getName(),
170             System.currentTimeMillis(), 1);
171     }
172
173     /**
174      *
175      */

176     public void debug(Object JavaDoc message, Throwable JavaDoc t)
177     {
178         Syslog.log(Syslog.getLocalHostName(),
179             this, this.name, message, t, Syslog.DEBUG,
180             Thread.currentThread(), Thread.currentThread().getName(),
181             System.currentTimeMillis(), 1);
182     }
183
184     /**
185      *
186      */

187     public void info(Object JavaDoc message)
188     {
189         Syslog.log(Syslog.getLocalHostName(),
190             this, this.name, message, null, Syslog.INFO,
191             Thread.currentThread(), Thread.currentThread().getName(),
192             System.currentTimeMillis(), 1);
193     }
194
195     /**
196      *
197      */

198     public void info(Object JavaDoc message, Throwable JavaDoc t)
199     {
200         Syslog.log(Syslog.getLocalHostName(),
201             this, this.name, message, t, Syslog.INFO,
202             Thread.currentThread(), Thread.currentThread().getName(),
203             System.currentTimeMillis(), 1);
204     }
205
206     /**
207      *
208      */

209     public void warn(Object JavaDoc message)
210     {
211         Syslog.log(Syslog.getLocalHostName(),
212             this, this.name, message, null, Syslog.WARNING,
213             Thread.currentThread(), Thread.currentThread().getName(),
214             System.currentTimeMillis(), 1);
215     }
216
217     /**
218      *
219      */

220     public void warn(Object JavaDoc message, Throwable JavaDoc t)
221     {
222         Syslog.log(Syslog.getLocalHostName(),
223             this, this.name, message, t, Syslog.WARNING,
224             Thread.currentThread(), Thread.currentThread().getName(),
225             System.currentTimeMillis(), 1);
226     }
227
228     /**
229      *
230      */

231     public void error(Object JavaDoc message)
232     {
233         Syslog.log(Syslog.getLocalHostName(),
234             this, this.name, message, null, Syslog.ERROR,
235             Thread.currentThread(), Thread.currentThread().getName(),
236             System.currentTimeMillis(), 1);
237     }
238
239     /**
240      *
241      */

242     public void error(Object JavaDoc message, Throwable JavaDoc t)
243     {
244         Syslog.log(Syslog.getLocalHostName(),
245             this, this.name, message, t, Syslog.ERROR,
246             Thread.currentThread(), Thread.currentThread().getName(),
247             System.currentTimeMillis(), 1);
248     }
249
250     /**
251      *
252      */

253     public void fatal(Object JavaDoc message)
254     {
255         Syslog.log(Syslog.getLocalHostName(),
256             this, this.name, message, null, Syslog.FATAL,
257             Thread.currentThread(), Thread.currentThread().getName(),
258             System.currentTimeMillis(), 1);
259     }
260
261     /**
262      *
263      */

264     public void fatal(Object JavaDoc message, Throwable JavaDoc t)
265     {
266         Syslog.log(Syslog.getLocalHostName(),
267             this, this.name, message, t, Syslog.FATAL,
268             Thread.currentThread(), Thread.currentThread().getName(),
269             System.currentTimeMillis(), 1);
270     }
271 }
272
Popular Tags