001: /*
002: * Copyright 2005 Joe Walker
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package org.directwebremoting.util;
017:
018: import org.apache.commons.logging.Log;
019: import org.apache.commons.logging.LogFactory;
020:
021: /**
022: * This class is intended to be used by Logger when commons-logging is
023: * available, but to not force Logger itself to depend on commons-logging so
024: * Logger can catch the ClassDefNotFoundError and use other methods.
025: * @author Joe Walker [joe at getahead dot ltd dot uk]
026: */
027: public class CommonsLoggingOutput implements LoggingOutput {
028: /**
029: * Create a logger specific to commons-logging
030: * @param base The class to log against.
031: */
032: public CommonsLoggingOutput(Class<?> base) {
033: log = LogFactory.getLog(base);
034: }
035:
036: /* (non-Javadoc)
037: * @see org.directwebremoting.util.LoggingOutput#debug(java.lang.String)
038: */
039: public void debug(String message) {
040: log.debug(message);
041: }
042:
043: /* (non-Javadoc)
044: * @see org.directwebremoting.util.LoggingOutput#info(java.lang.String)
045: */
046: public void info(String message) {
047: log.info(message);
048: }
049:
050: /* (non-Javadoc)
051: * @see org.directwebremoting.util.LoggingOutput#warn(java.lang.String)
052: */
053: public void warn(String message) {
054: log.warn(message);
055: }
056:
057: /* (non-Javadoc)
058: * @see org.directwebremoting.util.LoggingOutput#warn(java.lang.String, java.lang.Throwable)
059: */
060: public void warn(String message, Throwable th) {
061: log.warn(message, th);
062: }
063:
064: /* (non-Javadoc)
065: * @see org.directwebremoting.util.LoggingOutput#error(java.lang.String)
066: */
067: public void error(String message) {
068: log.error(message);
069: }
070:
071: /* (non-Javadoc)
072: * @see org.directwebremoting.util.LoggingOutput#error(java.lang.String, java.lang.Throwable)
073: */
074: public void error(String message, Throwable th) {
075: log.error(message, th);
076: }
077:
078: /* (non-Javadoc)
079: * @see org.directwebremoting.util.LoggingOutput#fatal(java.lang.String)
080: */
081: public void fatal(String message) {
082: log.fatal(message);
083: }
084:
085: /* (non-Javadoc)
086: * @see org.directwebremoting.util.LoggingOutput#fatal(java.lang.String, java.lang.Throwable)
087: */
088: public void fatal(String message, Throwable th) {
089: log.fatal(message, th);
090: }
091:
092: /* (non-Javadoc)
093: * @see org.directwebremoting.util.LoggingOutput#isDebugEnabled()
094: */
095: public boolean isDebugEnabled() {
096: return log.isDebugEnabled();
097: }
098:
099: private final Log log;
100: }
|