1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portal.log;
24  
25  import com.liferay.portal.kernel.log.Log;
26  import com.liferay.portal.kernel.log.LogWrapper;
27  
28  import org.apache.log4j.Level;
29  import org.apache.log4j.Logger;
30  
31  /**
32   * <a href="Log4jLogImpl.java.html"><b><i>View Source</i></b></a>
33   *
34   * @author Brian Wing Shun Chan
35   *
36   */
37  public class Log4jLogImpl implements Log {
38  
39      public Log4jLogImpl(Logger logger) {
40          _logger = logger;
41      }
42  
43      public void debug(Object msg) {
44          _logger.log(_FQCN, Level.DEBUG, msg, null);
45      }
46  
47      public void debug(Throwable t) {
48          _logger.log(_FQCN, Level.DEBUG, null, t);
49      }
50  
51      public void debug(Object msg, Throwable t) {
52          _logger.log(_FQCN, Level.DEBUG, msg, t);
53      }
54  
55      public void error(Object msg) {
56          _logger.log(_FQCN, Level.ERROR, msg, null);
57      }
58  
59      public void error(Throwable t) {
60          _logger.log(_FQCN, Level.ERROR, null, t);
61      }
62  
63      public void error(Object msg, Throwable t) {
64          _logger.log(_FQCN, Level.ERROR, msg, t);
65      }
66  
67      public void fatal(Object msg) {
68          _logger.log(_FQCN, Level.FATAL, msg, null);
69      }
70  
71      public void fatal(Throwable t) {
72          _logger.log(_FQCN, Level.FATAL, null, t);
73      }
74  
75      public void fatal(Object msg, Throwable t) {
76          _logger.log(_FQCN, Level.FATAL, msg, t);
77      }
78  
79      public void info(Object msg) {
80          _logger.log(_FQCN, Level.INFO, msg, null);
81      }
82  
83      public void info(Throwable t) {
84          _logger.log(_FQCN, Level.INFO, null, t);
85      }
86  
87      public void info(Object msg, Throwable t) {
88          _logger.log(_FQCN, Level.INFO, msg, t);
89      }
90  
91      public boolean isDebugEnabled() {
92          return _logger.isDebugEnabled();
93      }
94  
95      public boolean isErrorEnabled() {
96          return _logger.isEnabledFor(Level.ERROR);
97      }
98  
99      public boolean isFatalEnabled() {
100         return _logger.isEnabledFor(Level.FATAL);
101     }
102 
103     public boolean isInfoEnabled() {
104         return _logger.isInfoEnabled();
105     }
106 
107     public boolean isTraceEnabled() {
108         return _logger.isTraceEnabled();
109     }
110 
111     public boolean isWarnEnabled() {
112         return _logger.isEnabledFor(Level.WARN);
113     }
114 
115     public void trace(Object msg) {
116         _logger.log(_FQCN, Level.TRACE, msg, null);
117     }
118 
119     public void trace(Throwable t) {
120         _logger.log(_FQCN, Level.TRACE, null, t);
121     }
122 
123     public void trace(Object msg, Throwable t) {
124         _logger.log(_FQCN, Level.TRACE, msg, t);
125     }
126 
127     public void warn(Object msg) {
128         _logger.log(_FQCN, Level.WARN, msg, null);
129     }
130 
131     public void warn(Throwable t) {
132         _logger.log(_FQCN, Level.WARN, null, t);
133     }
134 
135     public void warn(Object msg, Throwable t) {
136         _logger.log(_FQCN, Level.WARN, msg, t);
137     }
138 
139     private static final String _FQCN = LogWrapper.class.getName();
140 
141     private Logger _logger;
142 
143 }