1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17   * SOFTWARE.
18   */
19  
20  package com.liferay.portal.log;
21  
22  import com.liferay.portal.kernel.log.Log;
23  import com.liferay.portal.kernel.log.LogWrapper;
24  
25  import org.apache.log4j.Level;
26  import org.apache.log4j.Logger;
27  
28  /**
29   * <a href="Log4jLogImpl.java.html"><b><i>View Source</i></b></a>
30   *
31   * @author Brian Wing Shun Chan
32   *
33   */
34  public class Log4jLogImpl implements Log {
35  
36      public Log4jLogImpl(Logger logger) {
37          _logger = logger;
38      }
39  
40      public void debug(Object msg) {
41          _logger.log(_FQCN, Level.DEBUG, msg, null);
42      }
43  
44      public void debug(Throwable t) {
45          _logger.log(_FQCN, Level.DEBUG, null, t);
46      }
47  
48      public void debug(Object msg, Throwable t) {
49          _logger.log(_FQCN, Level.DEBUG, msg, t);
50      }
51  
52      public void error(Object msg) {
53          _logger.log(_FQCN, Level.ERROR, msg, null);
54      }
55  
56      public void error(Throwable t) {
57          _logger.log(_FQCN, Level.ERROR, null, t);
58      }
59  
60      public void error(Object msg, Throwable t) {
61          _logger.log(_FQCN, Level.ERROR, msg, t);
62      }
63  
64      public void fatal(Object msg) {
65          _logger.log(_FQCN, Level.FATAL, msg, null);
66      }
67  
68      public void fatal(Throwable t) {
69          _logger.log(_FQCN, Level.FATAL, null, t);
70      }
71  
72      public void fatal(Object msg, Throwable t) {
73          _logger.log(_FQCN, Level.FATAL, msg, t);
74      }
75  
76      public void info(Object msg) {
77          _logger.log(_FQCN, Level.INFO, msg, null);
78      }
79  
80      public void info(Throwable t) {
81          _logger.log(_FQCN, Level.INFO, null, t);
82      }
83  
84      public void info(Object msg, Throwable t) {
85          _logger.log(_FQCN, Level.INFO, msg, t);
86      }
87  
88      public boolean isDebugEnabled() {
89          return _logger.isDebugEnabled();
90      }
91  
92      public boolean isErrorEnabled() {
93          return _logger.isEnabledFor(Level.ERROR);
94      }
95  
96      public boolean isFatalEnabled() {
97          return _logger.isEnabledFor(Level.FATAL);
98      }
99  
100     public boolean isInfoEnabled() {
101         return _logger.isInfoEnabled();
102     }
103 
104     public boolean isTraceEnabled() {
105         return _logger.isTraceEnabled();
106     }
107 
108     public boolean isWarnEnabled() {
109         return _logger.isEnabledFor(Level.WARN);
110     }
111 
112     public void trace(Object msg) {
113         _logger.log(_FQCN, Level.TRACE, msg, null);
114     }
115 
116     public void trace(Throwable t) {
117         _logger.log(_FQCN, Level.TRACE, null, t);
118     }
119 
120     public void trace(Object msg, Throwable t) {
121         _logger.log(_FQCN, Level.TRACE, msg, t);
122     }
123 
124     public void warn(Object msg) {
125         _logger.log(_FQCN, Level.WARN, msg, null);
126     }
127 
128     public void warn(Throwable t) {
129         _logger.log(_FQCN, Level.WARN, null, t);
130     }
131 
132     public void warn(Object msg, Throwable t) {
133         _logger.log(_FQCN, Level.WARN, msg, t);
134     }
135 
136     private static final String _FQCN = LogWrapper.class.getName();
137 
138     private Logger _logger;
139 
140 }