KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > directwebremoting > util > CommonsLoggingOutput


1 /*
2  * Copyright 2005 Joe Walker
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.directwebremoting.util;
17
18 import org.apache.commons.logging.Log;
19 import org.apache.commons.logging.LogFactory;
20
21 /**
22  * This class is intended to be used by Logger when commons-logging is
23  * available, but to not force Logger itself to depend on commons-logging so
24  * Logger can catch the ClassDefNotFoundError and use other methods.
25  * @author Joe Walker [joe at getahead dot ltd dot uk]
26  */

27 public class CommonsLoggingOutput implements LoggingOutput
28 {
29     /**
30      * Create a logger specific to commons-logging
31      * @param base The class to log against.
32      */

33     public CommonsLoggingOutput(Class JavaDoc base)
34     {
35         log = LogFactory.getLog(base);
36     }
37
38     /* (non-Javadoc)
39      * @see org.directwebremoting.util.LoggingOutput#debug(java.lang.String)
40      */

41     public void debug(String JavaDoc message)
42     {
43         log.debug(message);
44     }
45
46     /* (non-Javadoc)
47      * @see org.directwebremoting.util.LoggingOutput#info(java.lang.String)
48      */

49     public void info(String JavaDoc message)
50     {
51         log.info(message);
52     }
53
54     /* (non-Javadoc)
55      * @see org.directwebremoting.util.LoggingOutput#warn(java.lang.String)
56      */

57     public void warn(String JavaDoc message)
58     {
59         log.warn(message);
60     }
61
62     /* (non-Javadoc)
63      * @see org.directwebremoting.util.LoggingOutput#warn(java.lang.String, java.lang.Throwable)
64      */

65     public void warn(String JavaDoc message, Throwable JavaDoc th)
66     {
67         log.warn(message, th);
68     }
69
70     /* (non-Javadoc)
71      * @see org.directwebremoting.util.LoggingOutput#error(java.lang.String)
72      */

73     public void error(String JavaDoc message)
74     {
75         log.error(message);
76     }
77
78     /* (non-Javadoc)
79      * @see org.directwebremoting.util.LoggingOutput#error(java.lang.String, java.lang.Throwable)
80      */

81     public void error(String JavaDoc message, Throwable JavaDoc th)
82     {
83         log.error(message, th);
84     }
85
86     /* (non-Javadoc)
87      * @see org.directwebremoting.util.LoggingOutput#fatal(java.lang.String)
88      */

89     public void fatal(String JavaDoc message)
90     {
91         log.fatal(message);
92     }
93
94     /* (non-Javadoc)
95      * @see org.directwebremoting.util.LoggingOutput#fatal(java.lang.String, java.lang.Throwable)
96      */

97     public void fatal(String JavaDoc message, Throwable JavaDoc th)
98     {
99         log.fatal(message, th);
100     }
101
102     /* (non-Javadoc)
103      * @see org.directwebremoting.util.LoggingOutput#isDebugEnabled()
104      */

105     public boolean isDebugEnabled()
106     {
107         return log.isDebugEnabled();
108     }
109
110     private final Log log;
111 }
112
Popular Tags