1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    *
5    *
6    *
7    * The contents of this file are subject to the terms of the Liferay Enterprise
8    * Subscription License ("License"). You may not use this file except in
9    * compliance with the License. You can obtain a copy of the License by
10   * contacting Liferay, Inc. See the License for the specific language governing
11   * permissions and limitations under the License, including but not limited to
12   * distribution rights 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  public class Log4jLogImpl implements Log {
37  
38      public Log4jLogImpl(Logger logger) {
39          _logger = logger;
40      }
41  
42      public void debug(Object msg) {
43          _logger.log(_FQCN, Level.DEBUG, msg, null);
44      }
45  
46      public void debug(Throwable t) {
47          _logger.log(_FQCN, Level.DEBUG, null, t);
48      }
49  
50      public void debug(Object msg, Throwable t) {
51          _logger.log(_FQCN, Level.DEBUG, msg, t);
52      }
53  
54      public void error(Object msg) {
55          _logger.log(_FQCN, Level.ERROR, msg, null);
56      }
57  
58      public void error(Throwable t) {
59          _logger.log(_FQCN, Level.ERROR, null, t);
60      }
61  
62      public void error(Object msg, Throwable t) {
63          _logger.log(_FQCN, Level.ERROR, msg, t);
64      }
65  
66      public void fatal(Object msg) {
67          _logger.log(_FQCN, Level.FATAL, msg, null);
68      }
69  
70      public void fatal(Throwable t) {
71          _logger.log(_FQCN, Level.FATAL, null, t);
72      }
73  
74      public void fatal(Object msg, Throwable t) {
75          _logger.log(_FQCN, Level.FATAL, msg, t);
76      }
77  
78      public void info(Object msg) {
79          _logger.log(_FQCN, Level.INFO, msg, null);
80      }
81  
82      public void info(Throwable t) {
83          _logger.log(_FQCN, Level.INFO, null, t);
84      }
85  
86      public void info(Object msg, Throwable t) {
87          _logger.log(_FQCN, Level.INFO, msg, t);
88      }
89  
90      public boolean isDebugEnabled() {
91          return _logger.isDebugEnabled();
92      }
93  
94      public boolean isErrorEnabled() {
95          return _logger.isEnabledFor(Level.ERROR);
96      }
97  
98      public boolean isFatalEnabled() {
99          return _logger.isEnabledFor(Level.FATAL);
100     }
101 
102     public boolean isInfoEnabled() {
103         return _logger.isInfoEnabled();
104     }
105 
106     public boolean isTraceEnabled() {
107         return _logger.isTraceEnabled();
108     }
109 
110     public boolean isWarnEnabled() {
111         return _logger.isEnabledFor(Level.WARN);
112     }
113 
114     public void trace(Object msg) {
115         _logger.log(_FQCN, Level.TRACE, msg, null);
116     }
117 
118     public void trace(Throwable t) {
119         _logger.log(_FQCN, Level.TRACE, null, t);
120     }
121 
122     public void trace(Object msg, Throwable t) {
123         _logger.log(_FQCN, Level.TRACE, msg, t);
124     }
125 
126     public void warn(Object msg) {
127         _logger.log(_FQCN, Level.WARN, msg, null);
128     }
129 
130     public void warn(Throwable t) {
131         _logger.log(_FQCN, Level.WARN, null, t);
132     }
133 
134     public void warn(Object msg, Throwable t) {
135         _logger.log(_FQCN, Level.WARN, msg, t);
136     }
137 
138     private static final String _FQCN = LogWrapper.class.getName();
139 
140     private Logger _logger;
141 
142 }