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