001: /*
002: * Copyright (C) The DNA Group. All rights reserved.
003: *
004: * This software is published under the terms of the DNA
005: * Software License version 1.1, a copy of which has been included
006: * with this distribution in the LICENSE.txt file.
007: */
008: package org.codehaus.dna.impl;
009:
010: import org.codehaus.dna.Logger;
011:
012: /**
013: * Logging facade implmentation for Apache Logkit project.
014: * The following lists the mapping between DNA log levels
015: * and LogKit log levels.
016: *
017: * <ul>
018: * <li>trace ==> debug</li>
019: * <li>debug ==> debug</li>
020: * <li>info ==> info</li>
021: * <li>warn ==> warn</li>
022: * <li>error ==> error</li>
023: * </ul>
024: *
025: * @version $Revision: 1.2 $ $Date: 2004/05/01 09:51:48 $
026: */
027: public class LogkitLogger implements Logger {
028: /**
029: * The Logkit logger.
030: */
031: private final org.apache.log.Logger m_logger;
032:
033: /**
034: * Create an instance of LogKit logger facade.
035: *
036: * @param logger the logkit logger
037: */
038: public LogkitLogger(final org.apache.log.Logger logger) {
039: if (null == logger) {
040: throw new NullPointerException("logger");
041: }
042: m_logger = logger;
043: }
044:
045: /**
046: * Log a trace message.
047: *
048: * @param message the message
049: */
050: public void trace(final String message) {
051: m_logger.debug(message);
052: }
053:
054: /**
055: * Log a trace message with an associated throwable.
056: *
057: * @param message the message
058: * @param throwable the throwable
059: */
060: public void trace(final String message, final Throwable throwable) {
061: m_logger.debug(message, throwable);
062: }
063:
064: /**
065: * Return true if a trace message will be logged.
066: *
067: * @return true if message will be logged
068: */
069: public boolean isTraceEnabled() {
070: return m_logger.isDebugEnabled();
071: }
072:
073: /**
074: * Log a debug message.
075: *
076: * @param message the message
077: */
078: public void debug(final String message) {
079: m_logger.debug(message);
080: }
081:
082: /**
083: * Log a debug message with an associated throwable.
084: *
085: * @param message the message
086: * @param throwable the throwable
087: */
088: public void debug(final String message, final Throwable throwable) {
089: m_logger.debug(message, throwable);
090: }
091:
092: /**
093: * Return true if a debug message will be logged.
094: *
095: * @return true if message will be logged
096: */
097: public boolean isDebugEnabled() {
098: return m_logger.isDebugEnabled();
099: }
100:
101: /**
102: * Log a info message.
103: *
104: * @param message the message
105: */
106: public void info(final String message) {
107: m_logger.info(message);
108: }
109:
110: /**
111: * Log a info message with an associated throwable.
112: *
113: * @param message the message
114: * @param throwable the throwable
115: */
116: public void info(final String message, final Throwable throwable) {
117: m_logger.info(message, throwable);
118: }
119:
120: /**
121: * Return true if an info message will be logged.
122: *
123: * @return true if message will be logged
124: */
125: public boolean isInfoEnabled() {
126: return m_logger.isInfoEnabled();
127: }
128:
129: /**
130: * Log a warn message.
131: *
132: * @param message the message
133: */
134: public void warn(final String message) {
135: m_logger.warn(message);
136: }
137:
138: /**
139: * Log a warn message with an associated throwable.
140: *
141: * @param message the message
142: * @param throwable the throwable
143: */
144: public void warn(final String message, final Throwable throwable) {
145: m_logger.warn(message, throwable);
146: }
147:
148: /**
149: * Return true if a warn message will be logged.
150: *
151: * @return true if message will be logged
152: */
153: public boolean isWarnEnabled() {
154: return m_logger.isWarnEnabled();
155: }
156:
157: /**
158: * Log a error message.
159: *
160: * @param message the message
161: */
162: public void error(final String message) {
163: m_logger.error(message);
164: }
165:
166: /**
167: * Log a error message with an associated throwable.
168: *
169: * @param message the message
170: * @param throwable the throwable
171: */
172: public void error(final String message, final Throwable throwable) {
173: m_logger.error(message, throwable);
174: }
175:
176: /**
177: * Return true if a error message will be logged.
178: *
179: * @return true if message will be logged
180: */
181: public boolean isErrorEnabled() {
182: return m_logger.isErrorEnabled();
183: }
184:
185: /**
186: * Get the child logger with specified name.
187: *
188: * @param name the name of child logger
189: * @return the child logger
190: */
191: public Logger getChildLogger(final String name) {
192: return new LogkitLogger(m_logger.getChildLogger(name));
193: }
194: }
|