1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portal.log;
16  
17  import com.liferay.portal.kernel.log.Log;
18  import com.liferay.portal.kernel.log.LogWrapper;
19  
20  import org.apache.log4j.Level;
21  import org.apache.log4j.Logger;
22  
23  /**
24   * <a href="Log4jLogImpl.java.html"><b><i>View Source</i></b></a>
25   *
26   * @author Brian Wing Shun Chan
27   */
28  public class Log4jLogImpl implements Log {
29  
30      public Log4jLogImpl(Logger logger) {
31          _logger = logger;
32      }
33  
34      public void debug(Object msg) {
35          _logger.log(_FQCN, Level.DEBUG, msg, null);
36      }
37  
38      public void debug(Throwable t) {
39          _logger.log(_FQCN, Level.DEBUG, null, t);
40      }
41  
42      public void debug(Object msg, Throwable t) {
43          _logger.log(_FQCN, Level.DEBUG, msg, t);
44      }
45  
46      public void error(Object msg) {
47          _logger.log(_FQCN, Level.ERROR, msg, null);
48      }
49  
50      public void error(Throwable t) {
51          _logger.log(_FQCN, Level.ERROR, null, t);
52      }
53  
54      public void error(Object msg, Throwable t) {
55          _logger.log(_FQCN, Level.ERROR, msg, t);
56      }
57  
58      public void fatal(Object msg) {
59          _logger.log(_FQCN, Level.FATAL, msg, null);
60      }
61  
62      public void fatal(Throwable t) {
63          _logger.log(_FQCN, Level.FATAL, null, t);
64      }
65  
66      public void fatal(Object msg, Throwable t) {
67          _logger.log(_FQCN, Level.FATAL, msg, t);
68      }
69  
70      public void info(Object msg) {
71          _logger.log(_FQCN, Level.INFO, msg, null);
72      }
73  
74      public void info(Throwable t) {
75          _logger.log(_FQCN, Level.INFO, null, t);
76      }
77  
78      public void info(Object msg, Throwable t) {
79          _logger.log(_FQCN, Level.INFO, msg, t);
80      }
81  
82      public boolean isDebugEnabled() {
83          return _logger.isDebugEnabled();
84      }
85  
86      public boolean isErrorEnabled() {
87          return _logger.isEnabledFor(Level.ERROR);
88      }
89  
90      public boolean isFatalEnabled() {
91          return _logger.isEnabledFor(Level.FATAL);
92      }
93  
94      public boolean isInfoEnabled() {
95          return _logger.isInfoEnabled();
96      }
97  
98      public boolean isTraceEnabled() {
99          return _logger.isTraceEnabled();
100     }
101 
102     public boolean isWarnEnabled() {
103         return _logger.isEnabledFor(Level.WARN);
104     }
105 
106     public void trace(Object msg) {
107         _logger.log(_FQCN, Level.TRACE, msg, null);
108     }
109 
110     public void trace(Throwable t) {
111         _logger.log(_FQCN, Level.TRACE, null, t);
112     }
113 
114     public void trace(Object msg, Throwable t) {
115         _logger.log(_FQCN, Level.TRACE, msg, t);
116     }
117 
118     public void warn(Object msg) {
119         _logger.log(_FQCN, Level.WARN, msg, null);
120     }
121 
122     public void warn(Throwable t) {
123         _logger.log(_FQCN, Level.WARN, null, t);
124     }
125 
126     public void warn(Object msg, Throwable t) {
127         _logger.log(_FQCN, Level.WARN, msg, t);
128     }
129 
130     private static final String _FQCN = LogWrapper.class.getName();
131 
132     private Logger _logger;
133 
134 }