1 /* |
1 /* |
2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
29 |
29 |
30 import java.util.StringTokenizer; |
30 import java.util.StringTokenizer; |
31 import java.util.logging.Level; |
31 import java.util.logging.Level; |
32 |
32 |
33 /** |
33 /** |
34 * This is a helper class that provides some conveniece methods wrapped around the |
34 * This is a helper class that provides some convenience methods wrapped around the |
35 * standard {@link java.util.logging.Logger} interface. |
35 * standard {@link java.util.logging.Logger} interface. |
36 * |
36 * |
37 * The class also makes sure that logger names of each Metro subsystem are consistent |
37 * The class also makes sure that logger names of each Metro subsystem are consistent |
38 * with each other. |
38 * with each other. |
39 * |
39 * |
127 return; |
127 return; |
128 } |
128 } |
129 logger.logp(level, componentClassName, getCallerMethodName(), message); |
129 logger.logp(level, componentClassName, getCallerMethodName(), message); |
130 } |
130 } |
131 |
131 |
|
132 public void log(final Level level, final String message, Object param1) { |
|
133 if (!this.logger.isLoggable(level)) { |
|
134 return; |
|
135 } |
|
136 logger.logp(level, componentClassName, getCallerMethodName(), message, param1); |
|
137 } |
|
138 |
|
139 public void log(final Level level, final String message, Object[] params) { |
|
140 if (!this.logger.isLoggable(level)) { |
|
141 return; |
|
142 } |
|
143 logger.logp(level, componentClassName, getCallerMethodName(), message, params); |
|
144 } |
|
145 |
132 public void log(final Level level, final String message, final Throwable thrown) { |
146 public void log(final Level level, final String message, final Throwable thrown) { |
133 if (!this.logger.isLoggable(level)) { |
147 if (!this.logger.isLoggable(level)) { |
134 return; |
148 return; |
135 } |
149 } |
136 logger.logp(level, componentClassName, getCallerMethodName(), message, thrown); |
150 logger.logp(level, componentClassName, getCallerMethodName(), message, thrown); |
141 return; |
155 return; |
142 } |
156 } |
143 logger.logp(Level.FINEST, componentClassName, getCallerMethodName(), message); |
157 logger.logp(Level.FINEST, componentClassName, getCallerMethodName(), message); |
144 } |
158 } |
145 |
159 |
|
160 public void finest(final String message, Object[] params) { |
|
161 if (!this.logger.isLoggable(Level.FINEST)) { |
|
162 return; |
|
163 } |
|
164 logger.logp(Level.FINEST, componentClassName, getCallerMethodName(), message, params); |
|
165 } |
|
166 |
146 public void finest(final String message, final Throwable thrown) { |
167 public void finest(final String message, final Throwable thrown) { |
147 if (!this.logger.isLoggable(Level.FINEST)) { |
168 if (!this.logger.isLoggable(Level.FINEST)) { |
148 return; |
169 return; |
149 } |
170 } |
150 logger.logp(Level.FINEST, componentClassName, getCallerMethodName(), message, thrown); |
171 logger.logp(Level.FINEST, componentClassName, getCallerMethodName(), message, thrown); |
155 return; |
176 return; |
156 } |
177 } |
157 logger.logp(Level.FINER, componentClassName, getCallerMethodName(), message); |
178 logger.logp(Level.FINER, componentClassName, getCallerMethodName(), message); |
158 } |
179 } |
159 |
180 |
|
181 public void finer(final String message, Object[] params) { |
|
182 if (!this.logger.isLoggable(Level.FINER)) { |
|
183 return; |
|
184 } |
|
185 logger.logp(Level.FINER, componentClassName, getCallerMethodName(), message, params); |
|
186 } |
|
187 |
160 public void finer(final String message, final Throwable thrown) { |
188 public void finer(final String message, final Throwable thrown) { |
161 if (!this.logger.isLoggable(Level.FINER)) { |
189 if (!this.logger.isLoggable(Level.FINER)) { |
162 return; |
190 return; |
163 } |
191 } |
164 logger.logp(Level.FINER, componentClassName, getCallerMethodName(), message, thrown); |
192 logger.logp(Level.FINER, componentClassName, getCallerMethodName(), message, thrown); |
183 return; |
211 return; |
184 } |
212 } |
185 logger.logp(Level.INFO, componentClassName, getCallerMethodName(), message); |
213 logger.logp(Level.INFO, componentClassName, getCallerMethodName(), message); |
186 } |
214 } |
187 |
215 |
|
216 public void info(final String message, Object[] params) { |
|
217 if (!this.logger.isLoggable(Level.INFO)) { |
|
218 return; |
|
219 } |
|
220 logger.logp(Level.INFO, componentClassName, getCallerMethodName(), message, params); |
|
221 } |
|
222 |
188 public void info(final String message, final Throwable thrown) { |
223 public void info(final String message, final Throwable thrown) { |
189 if (!this.logger.isLoggable(Level.INFO)) { |
224 if (!this.logger.isLoggable(Level.INFO)) { |
190 return; |
225 return; |
191 } |
226 } |
192 logger.logp(Level.INFO, componentClassName, getCallerMethodName(), message, thrown); |
227 logger.logp(Level.INFO, componentClassName, getCallerMethodName(), message, thrown); |
197 return; |
232 return; |
198 } |
233 } |
199 logger.logp(Level.CONFIG, componentClassName, getCallerMethodName(), message); |
234 logger.logp(Level.CONFIG, componentClassName, getCallerMethodName(), message); |
200 } |
235 } |
201 |
236 |
|
237 public void config(final String message, Object[] params) { |
|
238 if (!this.logger.isLoggable(Level.CONFIG)) { |
|
239 return; |
|
240 } |
|
241 logger.logp(Level.CONFIG, componentClassName, getCallerMethodName(), message, params); |
|
242 } |
|
243 |
202 public void config(final String message, final Throwable thrown) { |
244 public void config(final String message, final Throwable thrown) { |
203 if (!this.logger.isLoggable(Level.CONFIG)) { |
245 if (!this.logger.isLoggable(Level.CONFIG)) { |
204 return; |
246 return; |
205 } |
247 } |
206 logger.logp(Level.CONFIG, componentClassName, getCallerMethodName(), message, thrown); |
248 logger.logp(Level.CONFIG, componentClassName, getCallerMethodName(), message, thrown); |
211 return; |
253 return; |
212 } |
254 } |
213 logger.logp(Level.WARNING, componentClassName, getCallerMethodName(), message); |
255 logger.logp(Level.WARNING, componentClassName, getCallerMethodName(), message); |
214 } |
256 } |
215 |
257 |
|
258 public void warning(final String message, Object[] params) { |
|
259 if (!this.logger.isLoggable(Level.WARNING)) { |
|
260 return; |
|
261 } |
|
262 logger.logp(Level.WARNING, componentClassName, getCallerMethodName(), message, params); |
|
263 } |
|
264 |
216 public void warning(final String message, final Throwable thrown) { |
265 public void warning(final String message, final Throwable thrown) { |
217 if (!this.logger.isLoggable(Level.WARNING)) { |
266 if (!this.logger.isLoggable(Level.WARNING)) { |
218 return; |
267 return; |
219 } |
268 } |
220 logger.logp(Level.WARNING, componentClassName, getCallerMethodName(), message, thrown); |
269 logger.logp(Level.WARNING, componentClassName, getCallerMethodName(), message, thrown); |
223 public void severe(final String message) { |
272 public void severe(final String message) { |
224 if (!this.logger.isLoggable(Level.SEVERE)) { |
273 if (!this.logger.isLoggable(Level.SEVERE)) { |
225 return; |
274 return; |
226 } |
275 } |
227 logger.logp(Level.SEVERE, componentClassName, getCallerMethodName(), message); |
276 logger.logp(Level.SEVERE, componentClassName, getCallerMethodName(), message); |
|
277 } |
|
278 |
|
279 public void severe(final String message, Object[] params) { |
|
280 if (!this.logger.isLoggable(Level.SEVERE)) { |
|
281 return; |
|
282 } |
|
283 logger.logp(Level.SEVERE, componentClassName, getCallerMethodName(), message, params); |
228 } |
284 } |
229 |
285 |
230 public void severe(final String message, final Throwable thrown) { |
286 public void severe(final String message, final Throwable thrown) { |
231 if (!this.logger.isLoggable(Level.SEVERE)) { |
287 if (!this.logger.isLoggable(Level.SEVERE)) { |
232 return; |
288 return; |