View Javadoc

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