View Javadoc

1   /*
2   
3   This software is OSI Certified Open Source Software.
4   OSI Certified is a certification mark of the Open Source Initiative.
5   
6   The license (Mozilla version 1.0) can be read at the MMBase site.
7   See http://www.MMBase.org/license
8   
9   */
10  package net.sf.mmapps.commons.logging.impl;
11  
12  import org.apache.commons.logging.Log;
13  import org.mmbase.util.logging.Logger;
14  
15  /***
16   * Adaptor class to convert jakarta-commons Log calls to MMBase 1.7 Logger calls.<br/>
17   * <br/>
18   * There are some differences between commons-logging and MMBase 1.7 logging. First of all 
19   * MMBase 1.7 does not support creating log message that have a {@link java.lang.Throwable} as second argument, therefore the 
20   * methods that use the Throwable argument are rerouted to the methods without the argument. The second difference is that MMBase 
21   * uses some  different Logging levels. documentation about what is actualy called is documented in the method documentation.
22   * 
23   * @author Kees Jongenburger
24   */
25  public class MMBase17Logger implements Log {
26  
27  	protected Logger logger;
28  	
29  	/***
30  	 * creates a new adaptor 
31  	 * @param logger the logger to use
32  	 */
33  	public MMBase17Logger(Logger logger) {
34  		this.logger = logger;
35  	}
36  
37  	/***
38  	 * @return if debug is enabled in the MMBaseLogger
39  	 */
40  	public boolean isDebugEnabled() {
41  		return logger.isDebugEnabled();
42  	}
43  
44  	/***
45  	 * @return if service is enabled in the MMBaseLogger
46  	 */
47  	public boolean isErrorEnabled() {
48  		return logger.isServiceEnabled();
49  	}
50  
51  	/***
52  	 * @return is service is enabled in the MMBase logger
53  	 */
54  	public boolean isFatalEnabled() {
55  		return logger.isServiceEnabled();
56  	}
57  	/***
58  	 * @return is service is enabled in the MMBase logger
59  	 */
60  	public boolean isInfoEnabled() {
61  		return logger.isServiceEnabled();
62  	}
63  
64  	/***
65  	 * @return if debug is enabled in the MMBaseLogger
66  	 */
67  	public boolean isTraceEnabled() {
68  		return logger.isDebugEnabled();
69  	}
70  
71  	/***
72  	 * @return is service is enabled in the MMBaseLogger
73  	 */
74  	public boolean isWarnEnabled() {
75  		return logger.isServiceEnabled();
76  	}
77  
78  	/***
79  	 * calls {@link org.mmbase.util.logging.Logger#trace(java.lang.Object)}
80  	 */
81  	public void trace(Object object) {
82  		logger.trace(object);
83  	}
84  
85  	/***
86  	 * calls {@link org.mmbase.util.logging.Logger#trace(java.lang.Object)} , discard the throwable argument
87  	 */	
88  	public void trace(Object object, Throwable throwable) {
89  		logger.trace(object);
90  	}
91  
92  	/***
93  	 * calls {@link org.mmbase.util.logging.Logger#debug(java.lang.Object)}
94  	 */
95  	public void debug(Object object) {
96  		logger.debug(object);
97  	}
98  
99  	/***
100 	 * calls {@link org.mmbase.util.logging.Logger#debug(java.lang.Object)}, discards the throwable argument
101 	 */
102 	public void debug(Object object, Throwable throwable) {
103 		logger.debug(object);
104 	}
105 
106 	/***
107 	 * calls {@link org.mmbase.util.logging.Logger#info(java.lang.Object)}
108 	 */
109 	public void info(Object object) {
110 		logger.info(object);
111 	}
112 
113 	/***
114 	 * calls {@link org.mmbase.util.logging.Logger#info(java.lang.Object)} , discards the throwable argument
115 	 */
116 	public void info(Object object, Throwable throwable) {
117 		logger.info(object);
118 	}
119 
120 	/***
121 	 * calls {@link org.mmbase.util.logging.Logger#warn(java.lang.Object)}
122 	 */
123 	public void warn(Object object) {
124 		logger.warn(object);
125 	}
126 
127 	/***
128 	 * calls {@link org.mmbase.util.logging.Logger#warn(java.lang.Object)} , discards the throwable argument
129 	 */
130 	public void warn(Object object, Throwable throwable) {
131 		logger.warn(object);
132 
133 	}
134 	
135 	/***
136 	 * calls {@link org.mmbase.util.logging.Logger#error(java.lang.Object)} 
137 	 */
138 	public void error(Object object) {
139 		logger.error(object);
140 	}
141 	
142 	/***
143 	 * calls {@link org.mmbase.util.logging.Logger#error(java.lang.Object)}, discards the throwable argument 
144 	 */
145 	public void error(Object object, Throwable throwable) {
146 		logger.error(object);
147 	}
148 
149 	/***
150 	 * calls {@link org.mmbase.util.logging.Logger#fatal(java.lang.Object)} 
151 	 */
152 	public void fatal(Object object) {
153 		logger.fatal(object);
154 
155 	}
156 	
157 	/***
158 	 * calls {@link org.mmbase.util.logging.Logger#fatal(java.lang.Object)}, discards the throwable argument 
159 	 */
160 	public void fatal(Object object, Throwable throwable) {
161 		logger.fatal(object);
162 	}
163 }