001: /*
002: * Created on 2006.4.11
003: *
004: * TODO To change the template for this generated file go to
005: * Window - Preferences - Java - Code Style - Code Templates
006: */
007: package org.enhydra.snapper.logging;
008:
009: import java.util.Properties;
010:
011: import org.enhydra.snapper.api.RootException;
012:
013: import org.objectweb.util.monolog.Monolog;
014: import org.objectweb.util.monolog.api.Logger;
015: import org.objectweb.util.monolog.api.LoggerFactory;
016: import org.objectweb.util.monolog.api.BasicLevel;
017:
018: /**
019: * Implementation of LoggingManager interface.
020: */
021: public class MonologLoggingManager implements
022: org.enhydra.snapper.api.logging.LoggingManager {
023:
024: private String logerName;
025: private Logger logger = null;
026:
027: /**
028: * Configures StandardLoggingManager.
029: *
030: * @param cus an instance of CallbackUtilities used to get
031: * properties for configuring logging in Shark.
032: */
033: public void configure(Properties prop) {
034:
035: LoggerFactory lf = Monolog.getMonologFactory();
036:
037: String name = prop.getProperty("LoggerName");
038:
039: if (name != null)
040: logger = lf.getLogger(name);
041: else
042: logger = lf.getLogger("Enhydra");
043:
044: }
045:
046: //////////////////////////////////////////////////////////////////
047: // LoggingManager API implementation
048: //////////////////////////////////////////////////////////////////
049:
050: /**
051: * Log a message object with the <i>ERROR</i> Level.
052: *
053: * @param msg the message to log.
054: *
055: */
056: public void error(String msg) {
057: error(logerName, msg);
058: }
059:
060: /**
061: * Log a message object with the <i>ERROR</i> Level.
062: *
063: * @param msg the message to log.
064: * @param ex the exception to log, including its stack trace.
065: *
066: */
067: public void error(String msg, RootException ex) {
068: error(logerName, msg, ex);
069: }
070:
071: /**
072: * Log a message object with the <i>ERROR</i> Level.
073: *
074: * @param channel the log channel to be used for logging.
075: * @param msg the message to log.
076: *
077: */
078: public void error(String channel, String msg) {
079:
080: if (logger != null)
081: logger.log(BasicLevel.ERROR, msg);
082:
083: }
084:
085: /**
086: * Log a message object with the <i>ERROR</i> Level.
087: *
088: * @param channel the log channel to be used for logging.
089: * @param msg the message to log.
090: * @param ex the exception to log, including its stack trace.
091: *
092: */
093: public void error(String channel, String msg, RootException ex) {
094:
095: if (logger != null)
096: logger.log(BasicLevel.ERROR, msg, ex);
097:
098: }
099:
100: /**
101: * Log a message object with the <i>WARN</i> Level.
102: *
103: * @param msg the message to log.
104: *
105: */
106: public void warn(String msg) {
107: warn(logerName, msg);
108: }
109:
110: /**
111: * Log a message object with the <i>WARN</i> Level.
112: *
113: * @param msg the message to log.
114: * @param ex the exception to log, including its stack trace.
115: *
116: */
117: public void warn(String msg, RootException ex) {
118: warn(logerName, msg, ex);
119: }
120:
121: /**
122: * Log a message object with the <i>WARN</i> Level.
123: *
124: * @param channel the log channel to be used for logging.
125: * @param msg the message to log.
126: *
127: */
128: public void warn(String channel, String msg) {
129:
130: if (logger != null)
131: logger.log(BasicLevel.WARN, msg);
132: }
133:
134: /**
135: * Log a message object with the <i>WARN</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: */
142: public void warn(String channel, String msg, RootException ex) {
143: if (logger != null)
144: logger.log(BasicLevel.WARN, msg, ex);
145:
146: }
147:
148: /**
149: * Log a message object with the <i>INFO</i> Level.
150: *
151: * @param msg the message to log.
152: *
153: */
154: public void info(String msg) {
155: info(logerName, msg);
156: }
157:
158: /**
159: * Log a message object with the <i>INFO</i> Level.
160: *
161: * @param msg the message to log.
162: * @param ex the exception to log, including its stack trace.
163: *
164: */
165: public void info(String msg, RootException ex) {
166: info(logerName, msg, ex);
167: }
168:
169: /**
170: * Log a message object with the <i>INFO</i> Level.
171: *
172: * @param channel the log channel to be used for logging.
173: * @param msg the message to log.
174: *
175: */
176: public void info(String channel, String msg) {
177: if (logger != null)
178: logger.log(BasicLevel.INFO, msg);
179:
180: }
181:
182: /**
183: * Log a message object with the <i>INFO</i> Level.
184: *
185: * @param channel the log channel to be used for logging.
186: * @param msg the message to log.
187: * @param ex the exception to log, including its stack trace.
188: *
189: */
190: public void info(String channel, String msg, RootException ex) {
191: if (logger != null)
192: logger.log(BasicLevel.INFO, msg, ex);
193:
194: }
195:
196: /**
197: * Log a message object with the <i>DEBUG</i> level.
198: *
199: * @param msg the message to log.
200: *
201: */
202: public void debug(String msg) {
203: debug(logerName, msg);
204: }
205:
206: /**
207: * Log a message object with the <i>DEBUG</i> level.
208: *
209: * @param msg the message to log.
210: * @param ex the exception to log, including its stack trace.
211: *
212: */
213: public void debug(String msg, RootException ex) {
214: debug(logerName, msg, ex);
215: }
216:
217: /**
218: * Log a message object with the <i>DEBUG</i> level.
219: *
220: * @param channel the log channel to be used for logging.
221: * @param msg the message to log.
222: *
223: */
224: public void debug(String channel, String msg) {
225: if (logger != null)
226: logger.log(BasicLevel.DEBUG, msg);
227:
228: }
229:
230: /**
231: * Log a message object with the <i>DEBUG</i> level.
232: *
233: * @param channel the log channel to be used for logging.
234: * @param msg the message to log.
235: * @param ex the exception to log, including its stack trace.
236: *
237: */
238: public void debug(String channel, String msg, RootException ex) {
239: if (logger != null)
240: logger.log(BasicLevel.DEBUG, msg, ex);
241:
242: }
243:
244: }
|