001: // TOTO
002:
003: package org.apache.commons.logging.impl;
004:
005: import java.io.Serializable;
006:
007: import org.apache.commons.logging.Log;
008: import org.slf4j.Logger;
009:
010: /**
011: * Implementation of {@link Log org.apache.commons.logging.Log} interface which
012: * delegates all processing to a wrapped {@link Logger org.slf4j.Logger} instance.
013: *
014: * <p>JCL's FATAL and TRACE levels are mapped to ERROR and DEBUG respectively. All
015: * other levels map one to one.
016: *
017: * @author Ceki Gülcü
018: */
019: public class SLF4JLog implements Log, Serializable {
020:
021: private static final long serialVersionUID = 680728617011167209L;
022:
023: // in both Log4jLogger and Jdk14Logger classes in the original JCL, the
024: // logger instance is transient
025: private transient Logger logger;
026:
027: SLF4JLog(Logger logger) {
028: this .logger = logger;
029: }
030:
031: /**
032: * Directly delegates to the wrapped <code>org.slf4j.Logger</code> instance.
033: */
034: public boolean isDebugEnabled() {
035: return logger.isDebugEnabled();
036: }
037:
038: /**
039: * Directly delegates to the wrapped <code>org.slf4j.Logger</code> instance.
040: */
041: public boolean isErrorEnabled() {
042: return logger.isErrorEnabled();
043: }
044:
045: /**
046: * Delegates to the <code>isErrorEnabled<code> method of the wrapped
047: * <code>org.slf4j.Logger</code> instance.
048: */
049: public boolean isFatalEnabled() {
050: return logger.isErrorEnabled();
051: }
052:
053: /**
054: * Directly delegates to the wrapped <code>org.slf4j.Logger</code> instance.
055: */
056: public boolean isInfoEnabled() {
057: return logger.isInfoEnabled();
058: }
059:
060: /**
061: * Delegates to the <code>isDebugEnabled<code> method of the wrapped
062: * <code>org.slf4j.Logger</code> instance.
063: */
064: public boolean isTraceEnabled() {
065: return logger.isTraceEnabled();
066: }
067:
068: /**
069: * Directly delegates to the wrapped <code>org.slf4j.Logger</code> instance.
070: */
071: public boolean isWarnEnabled() {
072: return logger.isWarnEnabled();
073: }
074:
075: /**
076: * Converts the input parameter to String and then delegates to
077: * the debug method of the wrapped <code>org.slf4j.Logger</code> instance.
078: *
079: * @param message the message to log. Converted to {@link String}
080: */
081: public void trace(Object message) {
082: logger.trace(String.valueOf(message));
083: }
084:
085: /**
086: * Converts the first input parameter to String and then delegates to
087: * the debug method of the wrapped <code>org.slf4j.Logger</code> instance.
088: *
089: * @param message the message to log. Converted to {@link String}
090: * @param t the exception to log
091: */
092: public void trace(Object message, Throwable t) {
093: logger.trace(String.valueOf(message), t);
094: }
095:
096: /**
097: * Converts the input parameter to String and then delegates to the wrapped
098: * <code>org.slf4j.Logger</code> instance.
099: *
100: * @param message the message to log. Converted to {@link String}
101: */
102: public void debug(Object message) {
103: logger.debug(String.valueOf(message));
104: }
105:
106: /**
107: * Converts the first input parameter to String and then delegates to
108: * the wrapped <code>org.slf4j.Logger</code> instance.
109: *
110: * @param message the message to log. Converted to {@link String}
111: * @param t the exception to log
112: */
113: public void debug(Object message, Throwable t) {
114: logger.debug(String.valueOf(message), t);
115: }
116:
117: /**
118: * Converts the input parameter to String and then delegates to the wrapped
119: * <code>org.slf4j.Logger</code> instance.
120: *
121: * @param message the message to log. Converted to {@link String}
122: */
123: public void info(Object message) {
124: logger.info(String.valueOf(message));
125: }
126:
127: /**
128: * Converts the first input parameter to String and then delegates to
129: * the wrapped <code>org.slf4j.Logger</code> instance.
130: *
131: * @param message the message to log. Converted to {@link String}
132: * @param t the exception to log
133: */
134: public void info(Object message, Throwable t) {
135: logger.info(String.valueOf(message), t);
136: }
137:
138: /**
139: * Converts the input parameter to String and then delegates to the wrapped
140: * <code>org.slf4j.Logger</code> instance.
141: *
142: * @param message the message to log. Converted to {@link String}
143: */
144: public void warn(Object message) {
145: logger.warn(String.valueOf(message));
146: }
147:
148: /**
149: * Converts the first input parameter to String and then delegates to
150: * the wrapped <code>org.slf4j.Logger</code> instance.
151: *
152: * @param message the message to log. Converted to {@link String}
153: * @param t the exception to log
154: */
155: public void warn(Object message, Throwable t) {
156: logger.warn(String.valueOf(message), t);
157: }
158:
159: /**
160: * Converts the input parameter to String and then delegates to the wrapped
161: * <code>org.slf4j.Logger</code> instance.
162: *
163: * @param message the message to log. Converted to {@link String}
164: */
165: public void error(Object message) {
166: logger.error(String.valueOf(message));
167: }
168:
169: /**
170: * Converts the first input parameter to String and then delegates to
171: * the wrapped <code>org.slf4j.Logger</code> instance.
172: *
173: * @param message the message to log. Converted to {@link String}
174: * @param t the exception to log
175: */
176: public void error(Object message, Throwable t) {
177: logger.error(String.valueOf(message), t);
178: }
179:
180: /**
181: * Converts the input parameter to String and then delegates to
182: * the error method of the wrapped <code>org.slf4j.Logger</code> instance.
183: *
184: * @param message the message to log. Converted to {@link String}
185: */
186: public void fatal(Object message) {
187: logger.error(String.valueOf(message));
188: }
189:
190: /**
191: * Converts the first input parameter to String and then delegates to
192: * the error method of the wrapped <code>org.slf4j.Logger</code> instance.
193: *
194: * @param message the message to log. Converted to {@link String}
195: * @param t the exception to log
196: */
197: public void fatal(Object message, Throwable t) {
198: logger.error(String.valueOf(message), t);
199: }
200:
201: }
|