1
2
3
4
5
6
7
8 package org.codehaus.dna.impl;
9
10 import org.codehaus.dna.Logger;
11
12 /***
13 * Logging facade implmentation for Apache Logkit project.
14 * The following lists the mapping between DNA log levels
15 * and LogKit log levels.
16 *
17 * <ul>
18 * <li>trace ==> debug</li>
19 * <li>debug ==> debug</li>
20 * <li>info ==> info</li>
21 * <li>warn ==> warn</li>
22 * <li>error ==> error</li>
23 * </ul>
24 *
25 * @version $Revision: 1.2 $ $Date: 2004/05/01 09:51:48 $
26 */
27 public class LogkitLogger
28 implements Logger
29 {
30 /***
31 * The Logkit logger.
32 */
33 private final org.apache.log.Logger m_logger;
34
35 /***
36 * Create an instance of LogKit logger facade.
37 *
38 * @param logger the logkit logger
39 */
40 public LogkitLogger( final org.apache.log.Logger logger )
41 {
42 if( null == logger )
43 {
44 throw new NullPointerException( "logger" );
45 }
46 m_logger = logger;
47 }
48
49 /***
50 * Log a trace message.
51 *
52 * @param message the message
53 */
54 public void trace( final String message )
55 {
56 m_logger.debug( message );
57 }
58
59 /***
60 * Log a trace message with an associated throwable.
61 *
62 * @param message the message
63 * @param throwable the throwable
64 */
65 public void trace( final String message,
66 final Throwable throwable )
67 {
68 m_logger.debug( message, throwable );
69 }
70
71 /***
72 * Return true if a trace message will be logged.
73 *
74 * @return true if message will be logged
75 */
76 public boolean isTraceEnabled()
77 {
78 return m_logger.isDebugEnabled();
79 }
80
81 /***
82 * Log a debug message.
83 *
84 * @param message the message
85 */
86 public void debug( final String message )
87 {
88 m_logger.debug( message );
89 }
90
91 /***
92 * Log a debug message with an associated throwable.
93 *
94 * @param message the message
95 * @param throwable the throwable
96 */
97 public void debug( final String message,
98 final Throwable throwable )
99 {
100 m_logger.debug( message, throwable );
101 }
102
103 /***
104 * Return true if a debug message will be logged.
105 *
106 * @return true if message will be logged
107 */
108 public boolean isDebugEnabled()
109 {
110 return m_logger.isDebugEnabled();
111 }
112
113 /***
114 * Log a info message.
115 *
116 * @param message the message
117 */
118 public void info( final String message )
119 {
120 m_logger.info( message );
121 }
122
123 /***
124 * Log a info message with an associated throwable.
125 *
126 * @param message the message
127 * @param throwable the throwable
128 */
129 public void info( final String message,
130 final Throwable throwable )
131 {
132 m_logger.info( message, throwable );
133 }
134
135 /***
136 * Return true if an info message will be logged.
137 *
138 * @return true if message will be logged
139 */
140 public boolean isInfoEnabled()
141 {
142 return m_logger.isInfoEnabled();
143 }
144
145 /***
146 * Log a warn message.
147 *
148 * @param message the message
149 */
150 public void warn( final String message )
151 {
152 m_logger.warn( message );
153 }
154
155 /***
156 * Log a warn message with an associated throwable.
157 *
158 * @param message the message
159 * @param throwable the throwable
160 */
161 public void warn( final String message,
162 final Throwable throwable )
163 {
164 m_logger.warn( message, throwable );
165 }
166
167 /***
168 * Return true if a warn message will be logged.
169 *
170 * @return true if message will be logged
171 */
172 public boolean isWarnEnabled()
173 {
174 return m_logger.isWarnEnabled();
175 }
176
177 /***
178 * Log a error message.
179 *
180 * @param message the message
181 */
182 public void error( final String message )
183 {
184 m_logger.error( message );
185 }
186
187 /***
188 * Log a error message with an associated throwable.
189 *
190 * @param message the message
191 * @param throwable the throwable
192 */
193 public void error( final String message,
194 final Throwable throwable )
195 {
196 m_logger.error( message, throwable );
197 }
198
199 /***
200 * Return true if a error message will be logged.
201 *
202 * @return true if message will be logged
203 */
204 public boolean isErrorEnabled()
205 {
206 return m_logger.isErrorEnabled();
207 }
208
209 /***
210 * Get the child logger with specified name.
211 *
212 * @param name the name of child logger
213 * @return the child logger
214 */
215 public Logger getChildLogger( final String name )
216 {
217 return new LogkitLogger( m_logger.getChildLogger( name ) );
218 }
219 }