|
|||||||||||||||||||
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
Jdk14Logger.java | 100% | 100% | 100% | 100% |
|
1 |
/*
|
|
2 |
* Copyright (C) The DNA Group. All rights reserved.
|
|
3 |
*
|
|
4 |
* This software is published under the terms of the DNA
|
|
5 |
* Software License version 1.1, a copy of which has been included
|
|
6 |
* with this distribution in the LICENSE.txt file.
|
|
7 |
*/
|
|
8 |
package org.codehaus.dna.impl;
|
|
9 |
|
|
10 |
import java.util.logging.Level;
|
|
11 |
|
|
12 |
import org.codehaus.dna.Logger;
|
|
13 |
|
|
14 |
/**
|
|
15 |
* Logging facade implmentation for JDK1.4 logging toolkit.
|
|
16 |
* The following lists the mapping between DNA log levels
|
|
17 |
* and JDK1.4 log levels.
|
|
18 |
*
|
|
19 |
* <ul>
|
|
20 |
* <li>trace ==> finest</li>
|
|
21 |
* <li>debug ==> fine</li>
|
|
22 |
* <li>info ==> info</li>
|
|
23 |
* <li>warn ==> warning</li>
|
|
24 |
* <li>error ==> severe</li>
|
|
25 |
* </ul>
|
|
26 |
*
|
|
27 |
* @version $Revision: 1.2 $ $Date: 2004/05/01 09:51:48 $
|
|
28 |
*/
|
|
29 |
public class Jdk14Logger |
|
30 |
implements Logger
|
|
31 |
{ |
|
32 |
/**
|
|
33 |
* The JDK1.4 logger.
|
|
34 |
*/
|
|
35 |
private final java.util.logging.Logger m_logger;
|
|
36 |
|
|
37 |
/**
|
|
38 |
* Create an instance of JDK14Logger facade.
|
|
39 |
*
|
|
40 |
* @param logger the JDK1.4 logger.
|
|
41 |
*/
|
|
42 | 100 |
public Jdk14Logger( final java.util.logging.Logger logger )
|
43 |
{ |
|
44 | 100 |
if( null == logger ) |
45 |
{ |
|
46 | 4 |
throw new NullPointerException( "logger" ); |
47 |
} |
|
48 | 96 |
m_logger = logger; |
49 |
} |
|
50 |
|
|
51 |
/**
|
|
52 |
* Log a trace message.
|
|
53 |
*
|
|
54 |
* @param message the message
|
|
55 |
*/
|
|
56 | 8 |
public void trace( final String message ) |
57 |
{ |
|
58 | 8 |
m_logger.log( Level.FINEST, message ); |
59 |
} |
|
60 |
|
|
61 |
/**
|
|
62 |
* Log a trace message with an associated throwable.
|
|
63 |
*
|
|
64 |
* @param message the message
|
|
65 |
* @param throwable the throwable
|
|
66 |
*/
|
|
67 | 8 |
public void trace( final String message, |
68 |
final Throwable throwable ) |
|
69 |
{ |
|
70 | 8 |
m_logger.log( Level.FINEST, message, throwable ); |
71 |
} |
|
72 |
|
|
73 |
/**
|
|
74 |
* Return true if a trace message will be logged.
|
|
75 |
*
|
|
76 |
* @return true if message will be logged
|
|
77 |
*/
|
|
78 | 16 |
public boolean isTraceEnabled() |
79 |
{ |
|
80 | 16 |
return m_logger.isLoggable( Level.FINEST );
|
81 |
} |
|
82 |
|
|
83 |
/**
|
|
84 |
* Log a debug message.
|
|
85 |
*
|
|
86 |
* @param message the message
|
|
87 |
*/
|
|
88 | 8 |
public void debug( final String message ) |
89 |
{ |
|
90 | 8 |
m_logger.log( Level.FINE, message ); |
91 |
} |
|
92 |
|
|
93 |
/**
|
|
94 |
* Log a debug message with an associated throwable.
|
|
95 |
*
|
|
96 |
* @param message the message
|
|
97 |
* @param throwable the throwable
|
|
98 |
*/
|
|
99 | 8 |
public void debug( final String message, |
100 |
final Throwable throwable ) |
|
101 |
{ |
|
102 | 8 |
m_logger.log( Level.FINE, message, throwable ); |
103 |
} |
|
104 |
|
|
105 |
/**
|
|
106 |
* Return true if a debug message will be logged.
|
|
107 |
*
|
|
108 |
* @return true if message will be logged
|
|
109 |
*/
|
|
110 | 16 |
public boolean isDebugEnabled() |
111 |
{ |
|
112 | 16 |
return m_logger.isLoggable( Level.FINE );
|
113 |
} |
|
114 |
|
|
115 |
/**
|
|
116 |
* Log a info message.
|
|
117 |
*
|
|
118 |
* @param message the message
|
|
119 |
*/
|
|
120 | 8 |
public void info( final String message ) |
121 |
{ |
|
122 | 8 |
m_logger.log( Level.INFO, message ); |
123 |
} |
|
124 |
|
|
125 |
/**
|
|
126 |
* Log a info message with an associated throwable.
|
|
127 |
*
|
|
128 |
* @param message the message
|
|
129 |
* @param throwable the throwable
|
|
130 |
*/
|
|
131 | 8 |
public void info( final String message, |
132 |
final Throwable throwable ) |
|
133 |
{ |
|
134 | 8 |
m_logger.log( Level.INFO, message, throwable ); |
135 |
} |
|
136 |
|
|
137 |
/**
|
|
138 |
* Return true if an info message will be logged.
|
|
139 |
*
|
|
140 |
* @return true if message will be logged
|
|
141 |
*/
|
|
142 | 16 |
public boolean isInfoEnabled() |
143 |
{ |
|
144 | 16 |
return m_logger.isLoggable( Level.INFO );
|
145 |
} |
|
146 |
|
|
147 |
/**
|
|
148 |
* Log a warn message.
|
|
149 |
*
|
|
150 |
* @param message the message
|
|
151 |
*/
|
|
152 | 8 |
public void warn( final String message ) |
153 |
{ |
|
154 | 8 |
m_logger.log( Level.WARNING, message ); |
155 |
} |
|
156 |
|
|
157 |
/**
|
|
158 |
* Log a warn message with an associated throwable.
|
|
159 |
*
|
|
160 |
* @param message the message
|
|
161 |
* @param throwable the throwable
|
|
162 |
*/
|
|
163 | 8 |
public void warn( final String message, |
164 |
final Throwable throwable ) |
|
165 |
{ |
|
166 | 8 |
m_logger.log( Level.WARNING, message, throwable ); |
167 |
} |
|
168 |
|
|
169 |
/**
|
|
170 |
* Return true if a warn message will be logged.
|
|
171 |
*
|
|
172 |
* @return true if message will be logged
|
|
173 |
*/
|
|
174 | 16 |
public boolean isWarnEnabled() |
175 |
{ |
|
176 | 16 |
return m_logger.isLoggable( Level.WARNING );
|
177 |
} |
|
178 |
|
|
179 |
/**
|
|
180 |
* Log a error message.
|
|
181 |
*
|
|
182 |
* @param message the message
|
|
183 |
*/
|
|
184 | 4 |
public void error( final String message ) |
185 |
{ |
|
186 | 4 |
m_logger.log( Level.SEVERE, message ); |
187 |
} |
|
188 |
|
|
189 |
/**
|
|
190 |
* Log a error message with an associated throwable.
|
|
191 |
*
|
|
192 |
* @param message the message
|
|
193 |
* @param throwable the throwable
|
|
194 |
*/
|
|
195 | 4 |
public void error( final String message, |
196 |
final Throwable throwable ) |
|
197 |
{ |
|
198 | 4 |
m_logger.log( Level.SEVERE, message, throwable ); |
199 |
} |
|
200 |
|
|
201 |
/**
|
|
202 |
* Return true if a error message will be logged.
|
|
203 |
*
|
|
204 |
* @return true if message will be logged
|
|
205 |
*/
|
|
206 | 16 |
public boolean isErrorEnabled() |
207 |
{ |
|
208 | 16 |
return m_logger.isLoggable( Level.SEVERE );
|
209 |
} |
|
210 |
|
|
211 |
/**
|
|
212 |
* Get the child logger with specified name.
|
|
213 |
*
|
|
214 |
* @param name the name of child logger
|
|
215 |
* @return the child logger
|
|
216 |
*/
|
|
217 | 4 |
public Logger getChildLogger( final String name )
|
218 |
{ |
|
219 | 4 |
final String childName = m_logger.getName() + "." + name;
|
220 | 4 |
return new Jdk14Logger( java.util.logging. |
221 |
Logger.getLogger( childName ) ); |
|
222 |
} |
|
223 |
} |
|
224 |
|
|