001: /*
002: * Copyright (C) 1999-2004 <A href="http://www-ist.massey.ac.nz/JBDietrich" target="_top">Jens Dietrich</a>
003: *
004: * This library is free software; you can redistribute it and/or
005: * modify it under the terms of the GNU Lesser General Public
006: * License as published by the Free Software Foundation; either
007: * version 2 of the License, or (at your option) any later version.
008: *
009: * This library is distributed in the hope that it will be useful,
010: * but WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012: * Lesser General Public License for more details.
013: *
014: * You should have received a copy of the GNU Lesser General Public
015: * License along with this library; if not, write to the Free Software
016: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
017: */
018:
019: package org.mandarax.util.logging;
020:
021: import java.util.logging.*;
022:
023: /**
024: * Logger wrapping the jdk log facility.
025: * @author <A href="http://www-ist.massey.ac.nz/JBDietrich" target="_top">Jens Dietrich</A>
026: * @version 3.4 <7 March 05>
027: * @since 2.3.1
028: */
029: class JDKLogger implements Logger {
030: private java.util.logging.Logger logger = null;
031:
032: /**
033: * Constructor.
034: * @param the name of the logger.
035: */
036: JDKLogger(String loggerName) {
037: super ();
038: logger = java.util.logging.Logger.getLogger(loggerName);
039: }
040:
041: /**
042: * Log an error.
043: * @param message a message
044: * @param exception an exception or error
045: */
046: public void error(String message, Throwable exception) {
047: logger.log(Level.SEVERE, message, exception);
048: }
049:
050: /**
051: * Log a warning.
052: * @param message a message
053: * @param exception an exception or error
054: */
055: public void warn(String message, Throwable exception) {
056: logger.log(Level.WARNING, message, exception);
057: }
058:
059: /**
060: * Log an info message.
061: * @param message a message
062: * @param exception an exception or error
063: */
064: public void info(String message, Throwable exception) {
065: logger.log(Level.INFO, message, exception);
066: }
067:
068: /**
069: * Log a debug message.
070: * @param message a message
071: * @param exception an exception or error
072: */
073: public void debug(String message, Throwable exception) {
074: logger.log(Level.FINEST, message, exception);
075: }
076:
077: /**
078: * Log an error.
079: * @param message a message
080: */
081: public void error(String message) {
082: logger.log(Level.SEVERE, message);
083: }
084:
085: /**
086: * Log a warning.
087: * @param message a message
088: */
089: public void warn(String message) {
090: logger.log(Level.WARNING, message);
091: }
092:
093: /**
094: * Log an info message.
095: * @param message a message
096: */
097: public void info(String message) {
098: logger.log(Level.INFO, message);
099: }
100:
101: /**
102: * Log a debug message.
103: * @param message a message
104: */
105: public void debug(String message) {
106: logger.log(Level.FINEST, message);
107: }
108:
109: /**
110: * Indicates whether logging on the DEBUG level is enabled.
111: * @return a boolean
112: */
113: public boolean isDebugEnabled() {
114: return logger.getLevel().intValue() == Level.FINEST.intValue();
115: }
116:
117: /**
118: * Indicates whether logging on the INFO level is enabled.
119: * @return a boolean
120: */
121: public boolean isInfoEnabled() {
122: return logger.getLevel().intValue() <= Level.INFO.intValue();
123: }
124: }
|