1 package org.apache.turbine.util;
2
3 /* ====================================================================
4 * The Apache Software License, Version 1.1
5 *
6 * Copyright (c) 2001 The Apache Software Foundation. All rights
7 * 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 by the
24 * Apache Software Foundation (http://www.apache.org/)."
25 * Alternately, this acknowledgment may appear in the software itself,
26 * if and wherever such third-party acknowledgments normally appear.
27 *
28 * 4. The names "Apache" and "Apache Software Foundation" and
29 * "Apache Turbine" must not be used to endorse or promote products
30 * derived from this software without prior written permission. For
31 * written permission, please contact apache@apache.org.
32 *
33 * 5. Products derived from this software may not be called "Apache",
34 * "Apache Turbine", nor may "Apache" appear in their name, without
35 * prior written permission of the Apache Software Foundation.
36 *
37 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
38 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
39 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
40 * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
41 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
42 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
43 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
44 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
45 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
46 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
47 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
48 * SUCH DAMAGE.
49 * ====================================================================
50 *
51 * This software consists of voluntary contributions made by many
52 * individuals on behalf of the Apache Software Foundation. For more
53 * information on the Apache Software Foundation, please see
54 * <http://www.apache.org/>.
55 */
56
57 import org.apache.turbine.services.TurbineServices;
58 import org.apache.turbine.services.logging.Logger;
59 import org.apache.turbine.services.logging.LoggingService;
60
61 /***
62 * A facade class for {@link org.apache.turbine.services.logging.LoggingService}.
63 *
64 * Use this class to conviniently access the system's configured LoggingSerice.
65 * <P>
66 * @see org.apache.turbine.services.logging.TurbineLoggingService
67 * @author <a href="mailto:Tomasz.Zielinski@e-point.pl">Tomasz Zielinski</a>
68 */
69 public class Log
70 {
71 /***
72 * This method has been deprecated, attempts to shutdown logger service.
73 * @deprecated The service should be shut down by the broker class only.
74 */
75 public static void destroy()
76 {
77 LoggingService logger = (LoggingService)TurbineServices.getInstance()
78 .getService(LoggingService.SERVICE_NAME);
79 logger.shutdown();
80 }
81
82 /***
83 * This method returns default logger for Turbine System
84 *
85 * @return The default logger for system.
86 */
87 public static Logger getLogger()
88 {
89 LoggingService logger = (LoggingService)TurbineServices.getInstance()
90 .getService(LoggingService.SERVICE_NAME);
91 return logger.getLogger();
92 }
93
94 /***
95 * This method returns logger with given name if such logger exsists,
96 * or the default logger.
97 */
98 public static Logger getLogger(String logName)
99 {
100 LoggingService logger = (LoggingService)TurbineServices.getInstance()
101 .getService(LoggingService.SERVICE_NAME);
102 return logger.getLogger(logName);
103 }
104
105 /***
106 * This method sets the log level in default logger
107 */
108 public static void setLogLevel(int level)
109 {
110 LoggingService logger = (LoggingService)TurbineServices.getInstance()
111 .getService(LoggingService.SERVICE_NAME);
112 logger.setLogLevel(level);
113 }
114
115 /***
116 * This method sets the log level in the logger of given name
117 */
118 public static void setLogLevel(String logName, int level)
119 {
120 LoggingService logger = (LoggingService)TurbineServices.getInstance()
121 .getService(LoggingService.SERVICE_NAME);
122 logger.setLogLevel(logName, level);
123 }
124
125 /***
126 * This method sets format style of the default logger.
127 * Format tokens are described in RunDataFilter implementation.
128 *
129 * @see org.apache.turbine.services.logging.BaseRunDataFilter
130 *
131 * @param format String describing what information should be extracted from
132 * RunData
133 */
134 public static void setFormat(String format)
135 {
136 LoggingService logger = (LoggingService)TurbineServices.getInstance()
137 .getService(LoggingService.SERVICE_NAME);
138 logger.setFormat(format);
139 }
140
141 /***
142 * This method sets format style of the given logger.
143 * Format tokens are described in RunDataFilter implementation.
144 *
145 * @see org.apache.turbine.services.logging.BaseRunDataFilter
146 *
147 * @param format String describing what information should be extracted from
148 * RunData
149 */
150 public static void setFormat(String logName, String format)
151 {
152 LoggingService logger = (LoggingService)TurbineServices.getInstance()
153 .getService(LoggingService.SERVICE_NAME);
154 logger.setFormat(logName, format);
155 }
156
157 /***
158 * This is a log method with logLevel == DEBUG, printing is done by
159 * the default logger
160 */
161 public static void debug(String message)
162 {
163 LoggingService logger = (LoggingService)TurbineServices.getInstance()
164 .getService(LoggingService.SERVICE_NAME);
165 logger.debug(message);
166 }
167
168 /***
169 * This is a log method with logLevel == DEBUG, printing is done by
170 * the default logger
171 */
172 public static void debug(String message, Throwable t)
173 {
174 LoggingService logger = (LoggingService)TurbineServices.getInstance()
175 .getService(LoggingService.SERVICE_NAME);
176 logger.debug(message, t);
177 }
178
179 /***
180 * This is a log method with logLevel == DEBUG, printing is done by
181 * the given logger
182 */
183 public static void debug(String logName ,String message, Throwable t)
184 {
185 LoggingService logger = (LoggingService)TurbineServices.getInstance()
186 .getService(LoggingService.SERVICE_NAME);
187 logger.debug(logName, message, t);
188 }
189
190 /***
191 * This is a log method with logLevel == DEBUG, printing is done by
192 * the given logger
193 */
194 public static void debug(String logName, String message)
195 {
196 LoggingService logger = (LoggingService)TurbineServices.getInstance()
197 .getService(LoggingService.SERVICE_NAME);
198 logger.debug(logName, message);
199 }
200
201 /***
202 * This is a log method with logLevel == DEBUG, printing is done by
203 * the default logger
204 */
205 public static void debug(String message, RunData data)
206 {
207 LoggingService logger = (LoggingService)TurbineServices.getInstance()
208 .getService(LoggingService.SERVICE_NAME);
209 logger.debug(message, data);
210 }
211
212 /***
213 * This is a log method with logLevel == DEBUG, printing is done by
214 * the default logger
215 */
216 public static void debug(String message, RunData data, Throwable t)
217 {
218 LoggingService logger = (LoggingService)TurbineServices.getInstance()
219 .getService(LoggingService.SERVICE_NAME);
220 logger.debug(message, data, t);
221 }
222
223 /***
224 * This is a log method with logLevel == DEBUG, printing is done by
225 * the given logger
226 */
227 public static void debug(String logName,
228 String message,
229 RunData data,
230 Throwable t)
231 {
232 LoggingService logger = (LoggingService)TurbineServices.getInstance()
233 .getService(LoggingService.SERVICE_NAME);
234 logger.debug(logName, message, data, t);
235 }
236
237 /***
238 * This is a log method with logLevel == DEBUG, printing is done by
239 * the given logger
240 */
241 public static void debug(String logName, String message, RunData data)
242 {
243 LoggingService logger = (LoggingService)TurbineServices.getInstance()
244 .getService(LoggingService.SERVICE_NAME);
245 logger.debug(logName, message, data);
246 }
247
248 /***
249 * This is a log method with logLevel == INFO, printing is done by
250 * the default logger
251 */
252 public static void info(String message)
253 {
254 LoggingService logger = (LoggingService)TurbineServices.getInstance()
255 .getService(LoggingService.SERVICE_NAME);
256 logger.info(message);
257 }
258
259 /***
260 * This is a log method with logLevel == INFO, printing is done by
261 * the default logger
262 */
263 public static void info(String message, Throwable t)
264 {
265 LoggingService logger = (LoggingService)TurbineServices.getInstance()
266 .getService(LoggingService.SERVICE_NAME);
267 logger.info(message, t);
268 }
269
270 /***
271 * This is a log method with logLevel == INFO, printing is done by
272 * the given logger
273 */
274 public static void info(String logName, String message)
275 {
276 LoggingService logger = (LoggingService)TurbineServices.getInstance()
277 .getService(LoggingService.SERVICE_NAME);
278 logger.info(logName, message);
279 }
280
281 /***
282 * This is a log method with logLevel == INFO, printing is done by
283 * the given logger
284 */
285 public static void info(String logName, String message, Throwable t)
286 {
287 LoggingService logger = (LoggingService)TurbineServices.getInstance()
288 .getService(LoggingService.SERVICE_NAME);
289 logger.info(logName, message, t);
290 }
291
292 /***
293 * This is a log method with logLevel == INFO, printing is done by
294 * the default logger
295 */
296 public static void info(String message, RunData data)
297 {
298 LoggingService logger = (LoggingService)TurbineServices.getInstance()
299 .getService(LoggingService.SERVICE_NAME);
300 logger.info(message, data);
301 }
302
303 /***
304 * This is a log method with logLevel == INFO, printing is done by
305 * the default logger
306 */
307 public static void info(String message, RunData data, Throwable t)
308 {
309 LoggingService logger = (LoggingService)TurbineServices.getInstance()
310 .getService(LoggingService.SERVICE_NAME);
311 logger.info(message, data, t);
312 }
313
314 /***
315 * This is a log method with logLevel == INFO, printing is done by
316 * the given logger
317 */
318 public static void info(String logName, String message, RunData data)
319 {
320 LoggingService logger = (LoggingService)TurbineServices.getInstance()
321 .getService(LoggingService.SERVICE_NAME);
322 logger.info(logName, message, data);
323 }
324
325 /***
326 * This is a log method with logLevel == INFO, printing is done by
327 * the given logger
328 */
329 public static void info(String logName,
330 String message,
331 RunData data,
332 Throwable t)
333 {
334 LoggingService logger = (LoggingService)TurbineServices.getInstance()
335 .getService(LoggingService.SERVICE_NAME);
336 logger.info(logName, message, data, t);
337 }
338
339 /***
340 * This is a log method with logLevel == WARN, printing is done by
341 * the default logger
342 */
343 public static void warn(String message)
344 {
345 LoggingService logger = (LoggingService)TurbineServices.getInstance()
346 .getService(LoggingService.SERVICE_NAME);
347 logger.warn(message);
348 }
349
350 /***
351 * This is a log method with logLevel == WARN, printing is done by
352 * the default logger
353 */
354 public static void warn(String message, Throwable t)
355 {
356 LoggingService logger = (LoggingService)TurbineServices.getInstance()
357 .getService(LoggingService.SERVICE_NAME);
358 logger.warn(message, t);
359 }
360
361 /***
362 * This is a log method with logLevel == WARN, printing is done by
363 * the given logger
364 */
365 public static void warn(String logName, String message)
366 {
367 LoggingService logger = (LoggingService)TurbineServices.getInstance()
368 .getService(LoggingService.SERVICE_NAME);
369 logger.warn(logName, message);
370 }
371
372 /***
373 * This is a log method with logLevel == WARN, printing is done by
374 * the given logger
375 */
376 public static void warn(String logName, String message, Throwable t)
377 {
378 LoggingService logger = (LoggingService)TurbineServices.getInstance()
379 .getService(LoggingService.SERVICE_NAME);
380 logger.warn(logName, message, t);
381 }
382
383 /***
384 * This is a log method with logLevel == WARN, printing is done by
385 * the default logger
386 */
387 public static void warn(String message, RunData data)
388 {
389 LoggingService logger = (LoggingService)TurbineServices.getInstance()
390 .getService(LoggingService.SERVICE_NAME);
391 logger.warn(message, data);
392 }
393
394 /***
395 * This is a log method with logLevel == WARN, printing is done by
396 * the default logger
397 */
398 public static void warn(String message, RunData data, Throwable t)
399 {
400 LoggingService logger = (LoggingService)TurbineServices.getInstance()
401 .getService(LoggingService.SERVICE_NAME);
402 logger.warn(message, data, t);
403 }
404
405 /***
406 * This is a log method with logLevel == WARN, printing is done by
407 * the given logger
408 */
409 public static void warn(String logName, String message, RunData data)
410 {
411 LoggingService logger = (LoggingService)TurbineServices.getInstance()
412 .getService(LoggingService.SERVICE_NAME);
413 logger.warn(logName, message, data);
414 }
415
416 /***
417 * This is a log method with logLevel == WARN, printing is done by
418 * the given logger
419 */
420 public static void warn(String logName,
421 String message,
422 RunData data,
423 Throwable t)
424 {
425 LoggingService logger = (LoggingService)TurbineServices.getInstance()
426 .getService(LoggingService.SERVICE_NAME);
427 logger.warn(logName, message, data, t);
428 }
429
430 /***
431 * This is a log method with logLevel == ERROR, printing is done by
432 * the default logger
433 */
434 public static void error(String message)
435 {
436 LoggingService logger = (LoggingService)TurbineServices.getInstance()
437 .getService(LoggingService.SERVICE_NAME);
438 logger.error(message);
439 }
440
441 /***
442 * This is a log method with logLevel == ERROR, printing is done by
443 * the default logger
444 */
445 public static void error(String message, Throwable t)
446 {
447 LoggingService logger = (LoggingService)TurbineServices.getInstance()
448 .getService(LoggingService.SERVICE_NAME);
449 logger.error(message, t);
450 }
451
452 /***
453 * This is a log method with logLevel == ERROR, printing is done by
454 * the given logger
455 */
456 public static void error(String logName, String message)
457 {
458 LoggingService logger = (LoggingService)TurbineServices.getInstance()
459 .getService(LoggingService.SERVICE_NAME);
460 logger.error(logName, message);
461 }
462
463 /***
464 * This is a log method with logLevel == ERROR, printing is done by
465 * the given logger
466 */
467 public static void error(String logName, String message, Throwable t)
468 {
469 LoggingService logger = (LoggingService)TurbineServices.getInstance()
470 .getService(LoggingService.SERVICE_NAME);
471 logger.error(logName, message, t);
472 }
473
474 /***
475 * This is a log method with logLevel == ERROR, printing is done by
476 * the default logger
477 */
478 public static void error(String message, RunData data)
479 {
480 LoggingService logger = (LoggingService)TurbineServices.getInstance()
481 .getService(LoggingService.SERVICE_NAME);
482 logger.error(message, data);
483 }
484
485 /***
486 * This is a log method with logLevel == ERROR, printing is done by
487 * the default logger
488 */
489 public static void error(String message, RunData data, Throwable t)
490 {
491 LoggingService logger = (LoggingService)TurbineServices.getInstance()
492 .getService(LoggingService.SERVICE_NAME);
493 logger.error(message, data, t);
494 }
495
496 /***
497 * This is a log method with logLevel == ERROR, printing is done by
498 * the given logger
499 */
500 public static void error(String logName, String message, RunData data)
501 {
502 LoggingService logger = (LoggingService)TurbineServices.getInstance()
503 .getService(LoggingService.SERVICE_NAME);
504 logger.error(logName, message, data);
505 }
506
507 /***
508 * This is a log method with logLevel == ERROR, printing is done by
509 * the given logger
510 */
511 public static void error(String logName,
512 String message,
513 RunData data,
514 Throwable t)
515 {
516 LoggingService logger = (LoggingService)TurbineServices.getInstance()
517 .getService(LoggingService.SERVICE_NAME);
518 logger.error(logName, message, data, t);
519 }
520
521 /***
522 * This is a log method with logLevel == ERROR, printing is done by
523 * the default logger
524 */
525 public static void error(Throwable e)
526 {
527 error("", e);
528 }
529
530 /***
531 * This method has been deprecated.
532 * This is method is kept for historical reason.
533 *
534 * @deprecated You should use info or debug methods instead.
535 */
536 public static void note(String message)
537 {
538 LoggingService logger = (LoggingService)TurbineServices.getInstance()
539 .getService(LoggingService.SERVICE_NAME);
540 logger.info(message);
541 }
542
543 /***
544 * This method has been deprecated.
545 * This is method is kept for historical reason.
546 *
547 * @deprecated You should use info or debug methods instead.
548 */
549 public static void note(String logName, String message)
550 {
551 LoggingService logger = (LoggingService)TurbineServices.getInstance()
552 .getService(LoggingService.SERVICE_NAME);
553 logger.info(logName, message);
554 }
555 }
This page was automatically generated by Maven