1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 package org.slf4j.ext;
26
27 import org.slf4j.Logger;
28 import org.slf4j.Marker;
29 import org.slf4j.helpers.FormattingTuple;
30 import org.slf4j.helpers.MessageFormatter;
31 import org.slf4j.spi.LocationAwareLogger;
32
33
34
35
36
37
38
39
40 public class LoggerWrapper implements Logger {
41
42
43
44
45
46
47
48
49
50 protected final Logger logger;
51 final String fqcn;
52
53 protected final boolean instanceofLAL;
54
55 public LoggerWrapper(Logger logger, String fqcn) {
56 this.logger = logger;
57 this.fqcn = fqcn;
58 if (logger instanceof LocationAwareLogger) {
59 instanceofLAL = true;
60 } else {
61 instanceofLAL = false;
62 }
63 }
64
65
66
67
68 public boolean isTraceEnabled() {
69 return logger.isTraceEnabled();
70 }
71
72
73
74
75 public boolean isTraceEnabled(Marker marker) {
76 return logger.isTraceEnabled(marker);
77 }
78
79
80
81
82 public void trace(String msg) {
83 if (!logger.isTraceEnabled())
84 return;
85
86 if (instanceofLAL) {
87 ((LocationAwareLogger) logger).log(null, fqcn, LocationAwareLogger.TRACE_INT, msg, null, null);
88 } else {
89 logger.trace(msg);
90 }
91 }
92
93
94
95
96 public void trace(String format, Object arg) {
97 if (!logger.isTraceEnabled())
98 return;
99
100 if (instanceofLAL) {
101 String formattedMessage = MessageFormatter.format(format, arg).getMessage();
102 ((LocationAwareLogger) logger).log(null, fqcn, LocationAwareLogger.TRACE_INT, formattedMessage, new Object[] { arg }, null);
103 } else {
104 logger.trace(format, arg);
105 }
106 }
107
108
109
110
111 public void trace(String format, Object arg1, Object arg2) {
112 if (!logger.isTraceEnabled())
113 return;
114
115 if (instanceofLAL) {
116 String formattedMessage = MessageFormatter.format(format, arg1, arg2).getMessage();
117 ((LocationAwareLogger) logger).log(null, fqcn, LocationAwareLogger.TRACE_INT, formattedMessage, new Object[] { arg1, arg2 }, null);
118 } else {
119 logger.trace(format, arg1, arg2);
120 }
121 }
122
123
124
125
126 public void trace(String format, Object... args) {
127 if (!logger.isTraceEnabled())
128 return;
129
130 if (instanceofLAL) {
131 String formattedMessage = MessageFormatter.arrayFormat(format, args).getMessage();
132 ((LocationAwareLogger) logger).log(null, fqcn, LocationAwareLogger.TRACE_INT, formattedMessage, args, null);
133 } else {
134 logger.trace(format, args);
135 }
136 }
137
138
139
140
141 public void trace(String msg, Throwable t) {
142 if (!logger.isTraceEnabled())
143 return;
144
145 if (instanceofLAL) {
146 ((LocationAwareLogger) logger).log(null, fqcn, LocationAwareLogger.TRACE_INT, msg, null, t);
147 } else {
148 logger.trace(msg, t);
149 }
150 }
151
152
153
154
155 public void trace(Marker marker, String msg) {
156 if (!logger.isTraceEnabled(marker))
157 return;
158 if (instanceofLAL) {
159 ((LocationAwareLogger) logger).log(marker, fqcn, LocationAwareLogger.TRACE_INT, msg, null, null);
160 } else {
161 logger.trace(marker, msg);
162 }
163 }
164
165
166
167
168 public void trace(Marker marker, String format, Object arg) {
169 if (!logger.isTraceEnabled(marker))
170 return;
171 if (instanceofLAL) {
172 String formattedMessage = MessageFormatter.format(format, arg).getMessage();
173 ((LocationAwareLogger) logger).log(marker, fqcn, LocationAwareLogger.TRACE_INT, formattedMessage, new Object[] { arg }, null);
174 } else {
175 logger.trace(marker, format, arg);
176 }
177 }
178
179
180
181
182 public void trace(Marker marker, String format, Object arg1, Object arg2) {
183 if (!logger.isTraceEnabled(marker))
184 return;
185 if (instanceofLAL) {
186 String formattedMessage = MessageFormatter.format(format, arg1, arg2).getMessage();
187 ((LocationAwareLogger) logger).log(marker, fqcn, LocationAwareLogger.TRACE_INT, formattedMessage, new Object[] { arg1, arg2 }, null);
188 } else {
189 logger.trace(marker, format, arg1, arg2);
190 }
191 }
192
193
194
195
196 public void trace(Marker marker, String format, Object... args) {
197 if (!logger.isTraceEnabled(marker))
198 return;
199 if (instanceofLAL) {
200 String formattedMessage = MessageFormatter.arrayFormat(format, args).getMessage();
201 ((LocationAwareLogger) logger).log(marker, fqcn, LocationAwareLogger.TRACE_INT, formattedMessage, args, null);
202 } else {
203 logger.trace(marker, format, args);
204 }
205 }
206
207
208
209
210 public void trace(Marker marker, String msg, Throwable t) {
211 if (!logger.isTraceEnabled(marker))
212 return;
213 if (instanceofLAL) {
214 ((LocationAwareLogger) logger).log(marker, fqcn, LocationAwareLogger.TRACE_INT, msg, null, t);
215 } else {
216 logger.trace(marker, msg, t);
217 }
218 }
219
220
221
222
223 public boolean isDebugEnabled() {
224 return logger.isDebugEnabled();
225 }
226
227
228
229
230 public boolean isDebugEnabled(Marker marker) {
231 return logger.isDebugEnabled(marker);
232 }
233
234
235
236
237 public void debug(String msg) {
238 if (!logger.isDebugEnabled())
239 return;
240
241 if (instanceofLAL) {
242 ((LocationAwareLogger) logger).log(null, fqcn, LocationAwareLogger.DEBUG_INT, msg, null, null);
243 } else {
244 logger.debug(msg);
245 }
246 }
247
248
249
250
251 public void debug(String format, Object arg) {
252 if (!logger.isDebugEnabled())
253 return;
254
255 if (instanceofLAL) {
256 String formattedMessage = MessageFormatter.format(format, arg).getMessage();
257 ((LocationAwareLogger) logger).log(null, fqcn, LocationAwareLogger.DEBUG_INT, formattedMessage, new Object[] { arg }, null);
258 } else {
259 logger.debug(format, arg);
260 }
261 }
262
263
264
265
266 public void debug(String format, Object arg1, Object arg2) {
267 if (!logger.isDebugEnabled())
268 return;
269
270 if (instanceofLAL) {
271 String formattedMessage = MessageFormatter.format(format, arg1, arg2).getMessage();
272 ((LocationAwareLogger) logger).log(null, fqcn, LocationAwareLogger.DEBUG_INT, formattedMessage, new Object[] { arg1, arg2 }, null);
273 } else {
274 logger.debug(format, arg1, arg2);
275 }
276 }
277
278
279
280
281 public void debug(String format, Object... argArray) {
282 if (!logger.isDebugEnabled())
283 return;
284
285 if (instanceofLAL) {
286 FormattingTuple ft = MessageFormatter.arrayFormat(format, argArray);
287 ((LocationAwareLogger) logger).log(null, fqcn, LocationAwareLogger.DEBUG_INT, ft.getMessage(), ft.getArgArray(), ft.getThrowable());
288 } else {
289 logger.debug(format, argArray);
290 }
291 }
292
293
294
295
296 public void debug(String msg, Throwable t) {
297 if (!logger.isDebugEnabled())
298 return;
299
300 if (instanceofLAL) {
301 ((LocationAwareLogger) logger).log(null, fqcn, LocationAwareLogger.DEBUG_INT, msg, null, t);
302 } else {
303 logger.debug(msg, t);
304 }
305 }
306
307
308
309
310 public void debug(Marker marker, String msg) {
311 if (!logger.isDebugEnabled(marker))
312 return;
313 if (instanceofLAL) {
314 ((LocationAwareLogger) logger).log(marker, fqcn, LocationAwareLogger.DEBUG_INT, msg, null, null);
315 } else {
316 logger.debug(marker, msg);
317 }
318 }
319
320
321
322
323 public void debug(Marker marker, String format, Object arg) {
324 if (!logger.isDebugEnabled(marker))
325 return;
326 if (instanceofLAL) {
327 FormattingTuple ft = MessageFormatter.format(format, arg);
328 ((LocationAwareLogger) logger).log(marker, fqcn, LocationAwareLogger.DEBUG_INT, ft.getMessage(), ft.getArgArray(), ft.getThrowable());
329 } else {
330 logger.debug(marker, format, arg);
331 }
332 }
333
334
335
336
337 public void debug(Marker marker, String format, Object arg1, Object arg2) {
338 if (!logger.isDebugEnabled(marker))
339 return;
340 if (instanceofLAL) {
341 String formattedMessage = MessageFormatter.format(format, arg1, arg2).getMessage();
342 ((LocationAwareLogger) logger).log(marker, fqcn, LocationAwareLogger.DEBUG_INT, formattedMessage, new Object[] { arg1, arg2 }, null);
343 } else {
344 logger.debug(marker, format, arg1, arg2);
345 }
346 }
347
348
349
350
351 public void debug(Marker marker, String format, Object... argArray) {
352 if (!logger.isDebugEnabled(marker))
353 return;
354 if (instanceofLAL) {
355
356 FormattingTuple ft = MessageFormatter.arrayFormat(format, argArray);
357 ((LocationAwareLogger) logger).log(marker, fqcn, LocationAwareLogger.DEBUG_INT, ft.getMessage(), argArray, ft.getThrowable());
358 } else {
359 logger.debug(marker, format, argArray);
360 }
361 }
362
363
364
365
366 public void debug(Marker marker, String msg, Throwable t) {
367 if (!logger.isDebugEnabled(marker))
368 return;
369 if (instanceofLAL) {
370 ((LocationAwareLogger) logger).log(marker, fqcn, LocationAwareLogger.DEBUG_INT, msg, null, t);
371 } else {
372 logger.debug(marker, msg, t);
373 }
374 }
375
376
377
378
379 public boolean isInfoEnabled() {
380 return logger.isInfoEnabled();
381 }
382
383
384
385
386 public boolean isInfoEnabled(Marker marker) {
387 return logger.isInfoEnabled(marker);
388 }
389
390
391
392
393 public void info(String msg) {
394 if (!logger.isInfoEnabled())
395 return;
396
397 if (instanceofLAL) {
398 ((LocationAwareLogger) logger).log(null, fqcn, LocationAwareLogger.INFO_INT, msg, null, null);
399 } else {
400 logger.info(msg);
401 }
402 }
403
404
405
406
407 public void info(String format, Object arg) {
408 if (!logger.isInfoEnabled())
409 return;
410
411 if (instanceofLAL) {
412 String formattedMessage = MessageFormatter.format(format, arg).getMessage();
413 ((LocationAwareLogger) logger).log(null, fqcn, LocationAwareLogger.INFO_INT, formattedMessage, new Object[] { arg }, null);
414 } else {
415 logger.info(format, arg);
416 }
417 }
418
419
420
421
422 public void info(String format, Object arg1, Object arg2) {
423 if (!logger.isInfoEnabled())
424 return;
425
426 if (instanceofLAL) {
427 String formattedMessage = MessageFormatter.format(format, arg1, arg2).getMessage();
428 ((LocationAwareLogger) logger).log(null, fqcn, LocationAwareLogger.INFO_INT, formattedMessage, new Object[] { arg1, arg2 }, null);
429 } else {
430 logger.info(format, arg1, arg2);
431 }
432 }
433
434
435
436
437 public void info(String format, Object... args) {
438 if (!logger.isInfoEnabled())
439 return;
440
441 if (instanceofLAL) {
442 String formattedMessage = MessageFormatter.arrayFormat(format, args).getMessage();
443 ((LocationAwareLogger) logger).log(null, fqcn, LocationAwareLogger.INFO_INT, formattedMessage, args, null);
444 } else {
445 logger.info(format, args);
446 }
447 }
448
449
450
451
452 public void info(String msg, Throwable t) {
453 if (!logger.isInfoEnabled())
454 return;
455
456 if (instanceofLAL) {
457 ((LocationAwareLogger) logger).log(null, fqcn, LocationAwareLogger.INFO_INT, msg, null, t);
458 } else {
459 logger.info(msg, t);
460 }
461 }
462
463
464
465
466 public void info(Marker marker, String msg) {
467 if (!logger.isInfoEnabled(marker))
468 return;
469 if (instanceofLAL) {
470 ((LocationAwareLogger) logger).log(marker, fqcn, LocationAwareLogger.INFO_INT, msg, null, null);
471 } else {
472 logger.info(marker, msg);
473 }
474 }
475
476
477
478
479 public void info(Marker marker, String format, Object arg) {
480 if (!logger.isInfoEnabled(marker))
481 return;
482 if (instanceofLAL) {
483 String formattedMessage = MessageFormatter.format(format, arg).getMessage();
484 ((LocationAwareLogger) logger).log(marker, fqcn, LocationAwareLogger.INFO_INT, formattedMessage, new Object[] { arg }, null);
485 } else {
486 logger.info(marker, format, arg);
487 }
488 }
489
490
491
492
493 public void info(Marker marker, String format, Object arg1, Object arg2) {
494 if (!logger.isInfoEnabled(marker))
495 return;
496 if (instanceofLAL) {
497 String formattedMessage = MessageFormatter.format(format, arg1, arg2).getMessage();
498 ((LocationAwareLogger) logger).log(marker, fqcn, LocationAwareLogger.INFO_INT, formattedMessage, new Object[] { arg1, arg2 }, null);
499 } else {
500 logger.info(marker, format, arg1, arg2);
501 }
502 }
503
504
505
506
507 public void info(Marker marker, String format, Object... args) {
508 if (!logger.isInfoEnabled(marker))
509 return;
510 if (instanceofLAL) {
511 String formattedMessage = MessageFormatter.arrayFormat(format, args).getMessage();
512 ((LocationAwareLogger) logger).log(marker, fqcn, LocationAwareLogger.INFO_INT, formattedMessage, args, null);
513 } else {
514 logger.info(marker, format, args);
515 }
516 }
517
518
519
520
521 public void info(Marker marker, String msg, Throwable t) {
522 if (!logger.isInfoEnabled(marker))
523 return;
524 if (instanceofLAL) {
525 ((LocationAwareLogger) logger).log(marker, fqcn, LocationAwareLogger.INFO_INT, msg, null, t);
526 } else {
527 logger.info(marker, msg, t);
528 }
529 }
530
531 public boolean isWarnEnabled() {
532 return logger.isWarnEnabled();
533 }
534
535
536
537
538 public boolean isWarnEnabled(Marker marker) {
539 return logger.isWarnEnabled(marker);
540 }
541
542
543
544
545 public void warn(String msg) {
546 if (!logger.isWarnEnabled())
547 return;
548
549 if (instanceofLAL) {
550 ((LocationAwareLogger) logger).log(null, fqcn, LocationAwareLogger.WARN_INT, msg, null, null);
551 } else {
552 logger.warn(msg);
553 }
554 }
555
556
557
558
559 public void warn(String format, Object arg) {
560 if (!logger.isWarnEnabled())
561 return;
562
563 if (instanceofLAL) {
564 String formattedMessage = MessageFormatter.format(format, arg).getMessage();
565 ((LocationAwareLogger) logger).log(null, fqcn, LocationAwareLogger.WARN_INT, formattedMessage, new Object[] { arg }, null);
566 } else {
567 logger.warn(format, arg);
568 }
569 }
570
571
572
573
574 public void warn(String format, Object arg1, Object arg2) {
575 if (!logger.isWarnEnabled())
576 return;
577
578 if (instanceofLAL) {
579 String formattedMessage = MessageFormatter.format(format, arg1, arg2).getMessage();
580 ((LocationAwareLogger) logger).log(null, fqcn, LocationAwareLogger.WARN_INT, formattedMessage, new Object[] { arg1, arg2 }, null);
581 } else {
582 logger.warn(format, arg1, arg2);
583 }
584 }
585
586
587
588
589 public void warn(String format, Object... args) {
590 if (!logger.isWarnEnabled())
591 return;
592
593 if (instanceofLAL) {
594 String formattedMessage = MessageFormatter.arrayFormat(format, args).getMessage();
595 ((LocationAwareLogger) logger).log(null, fqcn, LocationAwareLogger.WARN_INT, formattedMessage, args, null);
596 } else {
597 logger.warn(format, args);
598 }
599 }
600
601
602
603
604 public void warn(String msg, Throwable t) {
605 if (!logger.isWarnEnabled())
606 return;
607
608 if (instanceofLAL) {
609 ((LocationAwareLogger) logger).log(null, fqcn, LocationAwareLogger.WARN_INT, msg, null, t);
610 } else {
611 logger.warn(msg, t);
612 }
613 }
614
615
616
617
618 public void warn(Marker marker, String msg) {
619 if (!logger.isWarnEnabled(marker))
620 return;
621 if (instanceofLAL) {
622 ((LocationAwareLogger) logger).log(marker, fqcn, LocationAwareLogger.WARN_INT, msg, null, null);
623 } else {
624 logger.warn(marker, msg);
625 }
626 }
627
628
629
630
631 public void warn(Marker marker, String format, Object arg) {
632 if (!logger.isWarnEnabled(marker))
633 return;
634 if (instanceofLAL) {
635 String formattedMessage = MessageFormatter.format(format, arg).getMessage();
636 ((LocationAwareLogger) logger).log(marker, fqcn, LocationAwareLogger.WARN_INT, formattedMessage, new Object[] { arg }, null);
637 } else {
638 logger.warn(marker, format, arg);
639 }
640 }
641
642
643
644
645 public void warn(Marker marker, String format, Object arg1, Object arg2) {
646 if (!logger.isWarnEnabled(marker))
647 return;
648 if (instanceofLAL) {
649 String formattedMessage = MessageFormatter.format(format, arg1, arg2).getMessage();
650 ((LocationAwareLogger) logger).log(marker, fqcn, LocationAwareLogger.WARN_INT, formattedMessage, new Object[] { arg1, arg2 }, null);
651 } else {
652 logger.warn(marker, format, arg1, arg2);
653 }
654 }
655
656
657
658
659 public void warn(Marker marker, String format, Object... args) {
660 if (!logger.isWarnEnabled(marker))
661 return;
662 if (instanceofLAL) {
663 String formattedMessage = MessageFormatter.arrayFormat(format, args).getMessage();
664 ((LocationAwareLogger) logger).log(marker, fqcn, LocationAwareLogger.WARN_INT, formattedMessage, args, null);
665 } else {
666 logger.warn(marker, format, args);
667 }
668 }
669
670
671
672
673 public void warn(Marker marker, String msg, Throwable t) {
674 if (!logger.isWarnEnabled(marker))
675 return;
676 if (instanceofLAL) {
677 ((LocationAwareLogger) logger).log(marker, fqcn, LocationAwareLogger.WARN_INT, msg, null, t);
678 } else {
679 logger.warn(marker, msg, t);
680 }
681 }
682
683
684
685
686 public boolean isErrorEnabled() {
687 return logger.isErrorEnabled();
688 }
689
690
691
692
693 public boolean isErrorEnabled(Marker marker) {
694 return logger.isErrorEnabled(marker);
695 }
696
697
698
699
700 public void error(String msg) {
701 if (!logger.isErrorEnabled())
702 return;
703
704 if (instanceofLAL) {
705 ((LocationAwareLogger) logger).log(null, fqcn, LocationAwareLogger.ERROR_INT, msg, null, null);
706 } else {
707 logger.error(msg);
708 }
709 }
710
711
712
713
714 public void error(String format, Object arg) {
715 if (!logger.isErrorEnabled())
716 return;
717
718 if (instanceofLAL) {
719 String formattedMessage = MessageFormatter.format(format, arg).getMessage();
720 ((LocationAwareLogger) logger).log(null, fqcn, LocationAwareLogger.ERROR_INT, formattedMessage, new Object[] { arg }, null);
721 } else {
722 logger.error(format, arg);
723 }
724 }
725
726
727
728
729 public void error(String format, Object arg1, Object arg2) {
730 if (!logger.isErrorEnabled())
731 return;
732
733 if (instanceofLAL) {
734 String formattedMessage = MessageFormatter.format(format, arg1, arg2).getMessage();
735 ((LocationAwareLogger) logger).log(null, fqcn, LocationAwareLogger.ERROR_INT, formattedMessage, new Object[] { arg1, arg2 }, null);
736 } else {
737 logger.error(format, arg1, arg2);
738 }
739 }
740
741
742
743
744 public void error(String format, Object... args) {
745 if (!logger.isErrorEnabled())
746 return;
747
748 if (instanceofLAL) {
749 String formattedMessage = MessageFormatter.arrayFormat(format, args).getMessage();
750 ((LocationAwareLogger) logger).log(null, fqcn, LocationAwareLogger.ERROR_INT, formattedMessage, args, null);
751 } else {
752 logger.error(format, args);
753 }
754 }
755
756
757
758
759 public void error(String msg, Throwable t) {
760 if (!logger.isErrorEnabled())
761 return;
762
763 if (instanceofLAL) {
764 ((LocationAwareLogger) logger).log(null, fqcn, LocationAwareLogger.ERROR_INT, msg, null, t);
765 } else {
766 logger.error(msg, t);
767 }
768 }
769
770
771
772
773 public void error(Marker marker, String msg) {
774 if (!logger.isErrorEnabled(marker))
775 return;
776 if (instanceofLAL) {
777 ((LocationAwareLogger) logger).log(marker, fqcn, LocationAwareLogger.ERROR_INT, msg, null, null);
778 } else {
779 logger.error(marker, msg);
780 }
781 }
782
783
784
785
786 public void error(Marker marker, String format, Object arg) {
787 if (!logger.isErrorEnabled(marker))
788 return;
789 if (instanceofLAL) {
790 String formattedMessage = MessageFormatter.format(format, arg).getMessage();
791 ((LocationAwareLogger) logger).log(marker, fqcn, LocationAwareLogger.ERROR_INT, formattedMessage, new Object[] { arg }, null);
792 } else {
793 logger.error(marker, format, arg);
794 }
795 }
796
797
798
799
800 public void error(Marker marker, String format, Object arg1, Object arg2) {
801 if (!logger.isErrorEnabled(marker))
802 return;
803 if (instanceofLAL) {
804 String formattedMessage = MessageFormatter.format(format, arg1, arg2).getMessage();
805 ((LocationAwareLogger) logger).log(marker, fqcn, LocationAwareLogger.ERROR_INT, formattedMessage, new Object[] { arg1, arg2 }, null);
806 } else {
807 logger.error(marker, format, arg1, arg2);
808 }
809 }
810
811
812
813
814 public void error(Marker marker, String format, Object... args) {
815 if (!logger.isErrorEnabled(marker))
816 return;
817 if (instanceofLAL) {
818 String formattedMessage = MessageFormatter.arrayFormat(format, args).getMessage();
819 ((LocationAwareLogger) logger).log(marker, fqcn, LocationAwareLogger.ERROR_INT, formattedMessage, args, null);
820 } else {
821 logger.error(marker, format, args);
822 }
823 }
824
825
826
827
828 public void error(Marker marker, String msg, Throwable t) {
829 if (!logger.isErrorEnabled(marker))
830 return;
831 if (instanceofLAL) {
832 ((LocationAwareLogger) logger).log(marker, fqcn, LocationAwareLogger.ERROR_INT, msg, null, t);
833 } else {
834 logger.error(marker, msg, t);
835 }
836 }
837
838
839
840
841 public String getName() {
842 return logger.getName();
843 }
844 }