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: /**
022: * Simple logger - everything is logged to System.out or System.err.
023: * This is only a dummy and it is not recommended to use it.
024: * @see LoggerFactory
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: public class SimpleLogger implements Logger {
030:
031: /**
032: * Constructor.
033: * @param the name of the logger.
034: */
035: SimpleLogger(String loggerName) {
036: super ();
037: }
038:
039: /**
040: * Log an error.
041: * @param message a message
042: * @param exception an exception or error
043: */
044: public void error(String message, Throwable exception) {
045: write(System.err, message);
046: write(System.err, exception);
047: }
048:
049: /**
050: * Log a warning.
051: * @param message a message
052: * @param exception an exception or error
053: */
054: public void warn(String message, Throwable exception) {
055: write(System.err, message);
056: write(System.err, 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: write(System.err, message);
066: write(System.err, exception);
067: }
068:
069: /**
070: * Log a debug message.
071: * @param message a message
072: * @param exception an exception or error
073: */
074: public void debug(String message, Throwable exception) {
075: write(System.out, message);
076: write(System.err, exception);
077: }
078:
079: /**
080: * Log an error.
081: * @param message a message
082: */
083: public void error(String message) {
084: write(System.err, message);
085: }
086:
087: /**
088: * Log a message.
089: * @param message a message
090: */
091: public void warn(String message) {
092: write(System.out, message);
093: }
094:
095: /**
096: * Log a message.
097: * @param message a message
098: */
099: public void info(String message) {
100: write(System.out, message);
101: }
102:
103: /**
104: * Log a message.
105: * @param message a message
106: */
107: public void debug(String message) {
108: write(System.out, message);
109: }
110:
111: /**
112: * Indicates whether logging on the DEBUG level is enabled.
113: * @return a boolean
114: */
115: public boolean isDebugEnabled() {
116: return true;
117: }
118:
119: /**
120: * Indicates whether logging on the INFO level is enabled.
121: * @return a boolean
122: */
123: public boolean isInfoEnabled() {
124: return true;
125: }
126:
127: /**
128: * Write a log record.
129: * @param out a log target
130: * @param msg a message
131: */
132: protected void write(java.io.PrintStream out, String logRecord) {
133: out.println(logRecord);
134: }
135:
136: /**
137: * Write an exception.
138: * @param out a log target
139: * @param x an exception or error
140: */
141: protected void write(java.io.PrintStream out, Throwable x) {
142: x.printStackTrace(out);
143: }
144: }
|