KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > logging > impl > SLF4JLocationAwareLog


1 // TOTO
2

3 package org.apache.commons.logging.impl;
4
5 import org.apache.commons.logging.Log;
6 import org.slf4j.Logger;
7 import org.slf4j.spi.LocationAwareLogger;
8
9 /**
10  * Implementation of {@link Log org.apache.commons.logging.Log} interface which
11  * delegates all processing to a wrapped {@link Logger org.slf4j.Logger} instance.
12  *
13  * <p>JCL's FATAL and TRACE levels are mapped to ERROR and DEBUG respectively. All
14  * other levels map one to one.
15  *
16  * @author Ceki G&uuml;lc&uuml;
17  */

18 public class SLF4JLocationAwareLog implements Log {
19
20   private LocationAwareLogger logger;
21   private static final String JavaDoc FQCN = SLF4JLocationAwareLog.class.getName();
22   
23   SLF4JLocationAwareLog(LocationAwareLogger logger) {
24     this.logger = logger;
25   }
26
27   /**
28    * Directly delegates to the wrapped <code>org.slf4j.Logger</code> instance.
29    */

30   public boolean isDebugEnabled() {
31     return logger.isDebugEnabled();
32   }
33
34   /**
35    * Directly delegates to the wrapped <code>org.slf4j.Logger</code> instance.
36    */

37   public boolean isErrorEnabled() {
38     return logger.isErrorEnabled();
39   }
40
41   /**
42    * Delegates to the <code>isErrorEnabled<code> method of the wrapped
43    * <code>org.slf4j.Logger</code> instance.
44    */

45   public boolean isFatalEnabled() {
46     return logger.isErrorEnabled();
47   }
48
49   /**
50    * Directly delegates to the wrapped <code>org.slf4j.Logger</code> instance.
51    */

52   public boolean isInfoEnabled() {
53     return logger.isInfoEnabled();
54   }
55
56   /**
57    * Delegates to the <code>isTraceEnabled<code> method of the wrapped
58    * <code>org.slf4j.Logger</code> instance.
59    */

60   public boolean isTraceEnabled() {
61     return logger.isTraceEnabled();
62   }
63
64   /**
65    * Directly delegates to the wrapped <code>org.slf4j.Logger</code> instance.
66    */

67   public boolean isWarnEnabled() {
68     return logger.isWarnEnabled();
69   }
70
71   /**
72    * Converts the input parameter to String and then delegates to
73    * the debug method of the wrapped <code>org.slf4j.Logger</code> instance.
74    *
75    * @param message the message to log. Converted to {@link String}
76    */

77   public void trace(Object JavaDoc message) {
78     logger.log(null, FQCN, LocationAwareLogger.TRACE_INT, String.valueOf(message), null);
79   }
80
81   /**
82    * Converts the first input parameter to String and then delegates to
83    * the debug method of the wrapped <code>org.slf4j.Logger</code> instance.
84    *
85    * @param message the message to log. Converted to {@link String}
86    * @param t the exception to log
87    */

88   public void trace(Object JavaDoc message, Throwable JavaDoc t) {
89     logger.log(null, FQCN, LocationAwareLogger.TRACE_INT, String.valueOf(message), t);
90   }
91
92   /**
93    * Converts the input parameter to String and then delegates to the wrapped
94    * <code>org.slf4j.Logger</code> instance.
95    *
96    * @param message the message to log. Converted to {@link String}
97    */

98   public void debug(Object JavaDoc message) {
99     logger.log(null, FQCN, LocationAwareLogger.DEBUG_INT, String.valueOf(message), null);
100   }
101
102   /**
103    * Converts the first input parameter to String and then delegates to
104    * the wrapped <code>org.slf4j.Logger</code> instance.
105    *
106    * @param message the message to log. Converted to {@link String}
107    * @param t the exception to log
108    */

109   public void debug(Object JavaDoc message, Throwable JavaDoc t) {
110     logger.log(null, FQCN, LocationAwareLogger.DEBUG_INT, String.valueOf(message), t);
111   }
112
113   /**
114    * Converts the input parameter to String and then delegates to the wrapped
115    * <code>org.slf4j.Logger</code> instance.
116    *
117    * @param message the message to log. Converted to {@link String}
118    */

119   public void info(Object JavaDoc message) {
120     logger.log(null, FQCN, LocationAwareLogger.INFO_INT, String.valueOf(message), null);
121   }
122
123   /**
124    * Converts the first input parameter to String and then delegates to
125    * the wrapped <code>org.slf4j.Logger</code> instance.
126    *
127    * @param message the message to log. Converted to {@link String}
128    * @param t the exception to log
129    */

130   public void info(Object JavaDoc message, Throwable JavaDoc t) {
131     logger.log(null, FQCN, LocationAwareLogger.INFO_INT, String.valueOf(message), t);
132   }
133
134   /**
135    * Converts the input parameter to String and then delegates to the wrapped
136    * <code>org.slf4j.Logger</code> instance.
137    *
138    * @param message the message to log. Converted to {@link String}
139    */

140   public void warn(Object JavaDoc message) {
141     logger.log(null, FQCN, LocationAwareLogger.WARN_INT, String.valueOf(message), null);
142   }
143
144   /**
145    * Converts the first input parameter to String and then delegates to
146    * the wrapped <code>org.slf4j.Logger</code> instance.
147    *
148    * @param message the message to log. Converted to {@link String}
149    * @param t the exception to log
150    */

151   public void warn(Object JavaDoc message, Throwable JavaDoc t) {
152     logger.log(null, FQCN, LocationAwareLogger.WARN_INT, String.valueOf(message), t);
153   }
154
155   /**
156    * Converts the input parameter to String and then delegates to the wrapped
157    * <code>org.slf4j.Logger</code> instance.
158    *
159    * @param message the message to log. Converted to {@link String}
160    */

161   public void error(Object JavaDoc message) {
162     logger.log(null, FQCN, LocationAwareLogger.ERROR_INT, String.valueOf(message), null);
163   }
164
165   /**
166    * Converts the first input parameter to String and then delegates to
167    * the wrapped <code>org.slf4j.Logger</code> instance.
168    *
169    * @param message the message to log. Converted to {@link String}
170    * @param t the exception to log
171    */

172   public void error(Object JavaDoc message, Throwable JavaDoc t) {
173     logger.log(null, FQCN, LocationAwareLogger.ERROR_INT, String.valueOf(message), t);
174   }
175
176
177  
178   /**
179    * Converts the input parameter to String and then delegates to
180    * the error method of the wrapped <code>org.slf4j.Logger</code> instance.
181    *
182    * @param message the message to log. Converted to {@link String}
183    */

184   public void fatal(Object JavaDoc message) {
185     logger.log(null, FQCN, LocationAwareLogger.ERROR_INT, String.valueOf(message), null);
186   }
187
188   /**
189    * Converts the first input parameter to String and then delegates to
190    * the error method of the wrapped <code>org.slf4j.Logger</code> instance.
191    *
192    * @param message the message to log. Converted to {@link String}
193    * @param t the exception to log
194    */

195   public void fatal(Object JavaDoc message, Throwable JavaDoc t) {
196     logger.log(null, FQCN, LocationAwareLogger.ERROR_INT, String.valueOf(message), t);
197   }
198
199 }
Popular Tags