KickJava   Java API By Example, From Geeks To Geeks.

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


1 // TOTO
2

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

17 public class SLF4JLog implements Log {
18
19   private Logger logger;
20
21   SLF4JLog(Logger logger) {
22     this.logger = logger;
23   }
24
25   /**
26    * Directly delegates to the wrapped <code>org.slf4j.Logger</code> instance.
27    */

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

193   public void fatal(Object JavaDoc message, Throwable JavaDoc t) {
194     logger.error(String.valueOf(message), t);
195   }
196
197 }
Popular Tags