KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > avalon > logging > logkit > LogKitLogger


1 /*
2  * Copyright 2004 Apache Software Foundation
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
12  * implied.
13  *
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18 package org.apache.avalon.logging.logkit;
19
20 import org.apache.avalon.framework.logger.Logger;
21
22 /**
23  * The default LogKit wrapper class for Logger.
24  *
25  * @author <a HREF="mailto:dev@avalon.apache.org">Avalon Development Team</a>
26  * @version CVS $Revision: 1.2 $ $Date: 2004/02/21 13:27:03 $
27  */

28 public final class LogKitLogger
29     implements Logger
30 {
31     //underlying implementation to delegate to
32
private final org.apache.log.Logger m_logger;
33
34     /**
35      * Create a logger that delegates to specified logger.
36      *
37      * @param logImpl the LogKit logger to delegate to
38      */

39     public LogKitLogger( org.apache.log.Logger logImpl )
40     {
41         m_logger = logImpl;
42     }
43
44     /**
45      * Log a debug message.
46      *
47      * @param message the message
48      */

49     public final void debug( final String JavaDoc message )
50     {
51         m_logger.debug( message );
52     }
53
54     /**
55      * Log a debug message.
56      *
57      * @param message the message
58      * @param throwable the throwable
59      */

60     public final void debug( final String JavaDoc message, final Throwable JavaDoc throwable )
61     {
62         m_logger.debug( message, throwable );
63     }
64
65     /**
66      * Determine if messages of priority "debug" will be logged.
67      *
68      * @return true if "debug" messages will be logged
69      */

70     public final boolean isDebugEnabled()
71     {
72         return m_logger.isDebugEnabled();
73     }
74
75     /**
76      * Log a info message.
77      *
78      * @param message the message
79      */

80     public final void info( final String JavaDoc message )
81     {
82         m_logger.info( message );
83     }
84
85     /**
86      * Log a info message.
87      *
88      * @param message the message
89      * @param throwable the throwable
90      */

91     public final void info( final String JavaDoc message, final Throwable JavaDoc throwable )
92     {
93         m_logger.info( message, throwable );
94     }
95
96     /**
97      * Determine if messages of priority "info" will be logged.
98      *
99      * @return true if "info" messages will be logged
100      */

101     public final boolean isInfoEnabled()
102     {
103         return m_logger.isInfoEnabled();
104     }
105
106     /**
107      * Log a warn message.
108      *
109      * @param message the message
110      */

111     public final void warn( final String JavaDoc message )
112     {
113         m_logger.warn( message );
114     }
115
116     /**
117      * Log a warn message.
118      *
119      * @param message the message
120      * @param throwable the throwable
121      */

122     public final void warn( final String JavaDoc message, final Throwable JavaDoc throwable )
123     {
124         m_logger.warn( message, throwable );
125     }
126
127     /**
128      * Determine if messages of priority "warn" will be logged.
129      *
130      * @return true if "warn" messages will be logged
131      */

132     public final boolean isWarnEnabled()
133     {
134         return m_logger.isWarnEnabled();
135     }
136
137     /**
138      * Log a error message.
139      *
140      * @param message the message
141      */

142     public final void error( final String JavaDoc message )
143     {
144         m_logger.error( message );
145     }
146
147     /**
148      * Log a error message.
149      *
150      * @param message the message
151      * @param throwable the throwable
152      */

153     public final void error( final String JavaDoc message, final Throwable JavaDoc throwable )
154     {
155         m_logger.error( message, throwable );
156     }
157
158     /**
159      * Determine if messages of priority "error" will be logged.
160      *
161      * @return true if "error" messages will be logged
162      */

163     public final boolean isErrorEnabled()
164     {
165         return m_logger.isErrorEnabled();
166     }
167
168     /**
169      * Log a fatalError message.
170      *
171      * @param message the message
172      */

173     public final void fatalError( final String JavaDoc message )
174     {
175         m_logger.fatalError( message );
176     }
177
178     /**
179      * Log a fatalError message.
180      *
181      * @param message the message
182      * @param throwable the throwable
183      */

184     public final void fatalError( final String JavaDoc message, final Throwable JavaDoc throwable )
185     {
186         m_logger.fatalError( message, throwable );
187     }
188
189     /**
190      * Determine if messages of priority "fatalError" will be logged.
191      *
192      * @return true if "fatalError" messages will be logged
193      */

194     public final boolean isFatalErrorEnabled()
195     {
196         return m_logger.isFatalErrorEnabled();
197     }
198
199     /**
200      * Create a new child logger.
201      * The name of the child logger is [current-loggers-name].[passed-in-name]
202      * Throws <code>IllegalArgumentException</code> if name has an empty element name
203      *
204      * @param name the subname of this logger
205      * @return the new logger
206      */

207     public final Logger getChildLogger( final String JavaDoc name )
208     {
209         return new LogKitLogger( m_logger.getChildLogger( name ) );
210     }
211 }
212
Popular Tags