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