01: /*******************************************************************************
02: * Portions created by Sebastian Thomschke are copyright (c) 2005-2007 Sebastian
03: * Thomschke.
04: *
05: * All Rights Reserved. This program and the accompanying materials
06: * are made available under the terms of the Eclipse Public License v1.0
07: * which accompanies this distribution, and is available at
08: * http://www.eclipse.org/legal/epl-v10.html
09: *
10: * Contributors:
11: * Sebastian Thomschke - initial implementation.
12: *******************************************************************************/package net.sf.oval.logging;
13:
14: import org.apache.log4j.Level;
15:
16: /**
17: * Log4J Wrapper
18: * @author Sebastian Thomschke
19: */
20: public class LoggerL4JImpl implements Logger {
21: private final org.apache.log4j.Logger log;
22: private final String WRAPPER = "net.sf.oval.internal.Log";
23:
24: public LoggerL4JImpl(final String name) {
25: if (name == null)
26: throw new IllegalArgumentException("name cannot be null");
27: log = org.apache.log4j.Logger.getLogger(name);
28: }
29:
30: public void debug(final String msg) {
31: log.log(WRAPPER, Level.DEBUG, msg, null);
32: }
33:
34: public void debug(final String msg, final Throwable t) {
35: log.log(WRAPPER, Level.DEBUG, msg, t);
36: }
37:
38: public void error(final String msg) {
39: log.log(WRAPPER, Level.ERROR, msg, null);
40: }
41:
42: public void error(final String msg, final Throwable t) {
43: log.log(WRAPPER, Level.ERROR, msg, t);
44: }
45:
46: public void info(final String msg) {
47: log.log(WRAPPER, Level.INFO, msg, null);
48: }
49:
50: public void info(final String msg, final Throwable t) {
51: log.log(WRAPPER, Level.INFO, msg, t);
52: }
53:
54: public boolean isDebug() {
55: return log.isDebugEnabled();
56: }
57:
58: public boolean isError() {
59: return log.isEnabledFor(Level.ERROR);
60: }
61:
62: public boolean isInfo() {
63: return log.isInfoEnabled();
64: }
65:
66: public boolean isTrace() {
67: return log.isTraceEnabled();
68: }
69:
70: public boolean isWarn() {
71: return log.isEnabledFor(Level.WARN);
72: }
73:
74: public void trace(final String msg) {
75: log.log(WRAPPER, Level.TRACE, msg, null);
76: }
77:
78: public void trace(final String msg, final Throwable t) {
79: log.log(WRAPPER, Level.TRACE, msg, t);
80: }
81:
82: public void warn(final String msg) {
83: log.log(WRAPPER, Level.WARN, msg, null);
84: }
85:
86: public void warn(final String msg, final Throwable t) {
87: log.log(WRAPPER, Level.WARN, msg, t);
88: }
89: }
|