001: /**
002: * Miroslav Popov, Dec 20, 2005 miroslav.popov@gmail.com
003: */package org.enhydra.jawe.base.logger;
004:
005: import java.util.logging.Level;
006: import java.util.logging.Logger;
007:
008: /**
009: * @author Miroslav Popov
010: */
011: public class LoggingManager {
012:
013: private static final String defaultLogChannel = "JaWE";
014:
015: private static Logger logger = Logger
016: .getLogger(LoggingManager.class.getName());
017:
018: /**
019: * Log a message object with the <i>ERROR</i> Level.
020: *
021: * @param msg the message to log.
022: */
023: public void error(String msg) {
024: error(defaultLogChannel, msg);
025: }
026:
027: /**
028: * Log a message object with the <i>ERROR</i> Level.
029: *
030: * @param msg the message to log.
031: * @param ex the exception to log, including its stack trace.
032: */
033: public void error(String msg, Throwable ex) {
034: error(defaultLogChannel, msg, ex);
035: }
036:
037: /**
038: * Log a message object with the <i>ERROR</i> Level.
039: *
040: * @param channel the log channel to be used for logging.
041: * @param msg the message to log.
042: */
043: public void error(String channel, String msg) {
044: // System.err.println(msg);
045: logger.log(Level.SEVERE, msg);
046: }
047:
048: /**
049: * Log a message object with the <i>ERROR</i> Level.
050: *
051: * @param channel the log channel to be used for logging.
052: * @param msg the message to log.
053: * @param ex the exception to log, including its stack trace.
054: */
055: public void error(String channel, String msg, Throwable ex) {
056: // System.err.println(msg);
057: // ex.printStackTrace();
058: logger.log(Level.SEVERE, msg, ex);
059: }
060:
061: /**
062: * Log a message object with the <i>WARN</i> Level.
063: *
064: * @param msg the message to log.
065: */
066: public void warn(String msg) {
067: warn(defaultLogChannel, msg);
068: }
069:
070: /**
071: * Log a message object with the <i>WARN</i> Level.
072: *
073: * @param msg the message to log.
074: * @param ex the exception to log, including its stack trace.
075: */
076: public void warn(String msg, Throwable ex) {
077: warn(defaultLogChannel, msg, ex);
078: }
079:
080: /**
081: * Log a message object with the <i>WARN</i> Level.
082: *
083: * @param channel the log channel to be used for logging.
084: * @param msg the message to log.
085: */
086: public void warn(String channel, String msg) {
087: // System.err.println(msg);
088: logger.log(Level.WARNING, msg);
089: }
090:
091: /**
092: * Log a message object with the <i>WARN</i> Level.
093: *
094: * @param channel the log channel to be used for logging.
095: * @param msg the message to log.
096: * @param ex the exception to log, including its stack trace.
097: */
098: public void warn(String channel, String msg, Throwable ex) {
099: // System.err.println(msg);
100: // ex.printStackTrace();
101: logger.log(Level.WARNING, msg, ex);
102: }
103:
104: /**
105: * Log a message object with the <i>INFO</i> Level.
106: *
107: * @param msg the message to log.
108: */
109: public void info(String msg) {
110: info(defaultLogChannel, msg);
111: }
112:
113: /**
114: * Log a message object with the <i>INFO</i> Level.
115: *
116: * @param msg the message to log.
117: * @param ex the exception to log, including its stack trace.
118: */
119: public void info(String msg, Throwable ex) {
120: info(defaultLogChannel, msg, ex);
121: }
122:
123: /**
124: * Log a message object with the <i>INFO</i> Level.
125: *
126: * @param channel the log channel to be used for logging.
127: * @param msg the message to log.
128: */
129: public void info(String channel, String msg) {
130: // System.out.println(msg);
131: logger.log(Level.INFO, msg);
132: }
133:
134: /**
135: * Log a message object with the <i>INFO</i> Level.
136: *
137: * @param channel the log channel to be used for logging.
138: * @param msg the message to log.
139: * @param ex the exception to log, including its stack trace.
140: */
141: public void info(String channel, String msg, Throwable ex) {
142: // System.out.println(msg);
143: // ex.printStackTrace();
144: logger.log(Level.INFO, msg, ex);
145: }
146:
147: /**
148: * Log a message object with the <i>DEBUG</i> level.
149: *
150: * @param msg the message to log.
151: */
152: public void debug(String msg) {
153: debug(defaultLogChannel, msg);
154: }
155:
156: /**
157: * Log a message object with the <i>DEBUG</i> level.
158: *
159: * @param msg the message to log.
160: * @param ex the exception to log, including its stack trace.
161: */
162: public void debug(String msg, Throwable ex) {
163: debug(defaultLogChannel, msg, ex);
164: }
165:
166: /**
167: * Log a message object with the <i>DEBUG</i> level.
168: *
169: * @param channel the log channel to be used for logging.
170: * @param msg the message to log.
171: */
172: public void debug(String channel, String msg) {
173: // System.err.println(msg);
174: logger.log(Level.FINEST, msg);
175: }
176:
177: /**
178: * Log a message object with the <i>DEBUG</i> level.
179: *
180: * @param channel the log channel to be used for logging.
181: * @param msg the message to log.
182: * @param ex the exception to log, including its stack trace.
183: */
184: public void debug(String channel, String msg, Throwable ex) {
185: // System.err.println(msg);
186: // ex.printStackTrace();
187: logger.log(Level.FINEST, msg, ex);
188: }
189:
190: }
|