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