001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.log;
016    
017    import com.liferay.portal.kernel.log.Log;
018    import com.liferay.portal.kernel.log.LogWrapper;
019    
020    import org.apache.log4j.Level;
021    import org.apache.log4j.Logger;
022    
023    /**
024     * @author Brian Wing Shun Chan
025     */
026    public class Log4jLogImpl implements Log {
027    
028            public Log4jLogImpl(Logger logger) {
029                    _logger = logger;
030            }
031    
032            public void debug(Object msg) {
033                    _logger.log(_FQCN, Level.DEBUG, msg, null);
034            }
035    
036            public void debug(Throwable t) {
037                    _logger.log(_FQCN, Level.DEBUG, null, t);
038            }
039    
040            public void debug(Object msg, Throwable t) {
041                    _logger.log(_FQCN, Level.DEBUG, msg, t);
042            }
043    
044            public void error(Object msg) {
045                    _logger.log(_FQCN, Level.ERROR, msg, null);
046            }
047    
048            public void error(Throwable t) {
049                    _logger.log(_FQCN, Level.ERROR, null, t);
050            }
051    
052            public void error(Object msg, Throwable t) {
053                    _logger.log(_FQCN, Level.ERROR, msg, t);
054            }
055    
056            public void fatal(Object msg) {
057                    _logger.log(_FQCN, Level.FATAL, msg, null);
058            }
059    
060            public void fatal(Throwable t) {
061                    _logger.log(_FQCN, Level.FATAL, null, t);
062            }
063    
064            public void fatal(Object msg, Throwable t) {
065                    _logger.log(_FQCN, Level.FATAL, msg, t);
066            }
067    
068            public void info(Object msg) {
069                    _logger.log(_FQCN, Level.INFO, msg, null);
070            }
071    
072            public void info(Throwable t) {
073                    _logger.log(_FQCN, Level.INFO, null, t);
074            }
075    
076            public void info(Object msg, Throwable t) {
077                    _logger.log(_FQCN, Level.INFO, msg, t);
078            }
079    
080            public boolean isDebugEnabled() {
081                    return _logger.isDebugEnabled();
082            }
083    
084            public boolean isErrorEnabled() {
085                    return _logger.isEnabledFor(Level.ERROR);
086            }
087    
088            public boolean isFatalEnabled() {
089                    return _logger.isEnabledFor(Level.FATAL);
090            }
091    
092            public boolean isInfoEnabled() {
093                    return _logger.isInfoEnabled();
094            }
095    
096            public boolean isTraceEnabled() {
097                    return _logger.isTraceEnabled();
098            }
099    
100            public boolean isWarnEnabled() {
101                    return _logger.isEnabledFor(Level.WARN);
102            }
103    
104            public void trace(Object msg) {
105                    _logger.log(_FQCN, Level.TRACE, msg, null);
106            }
107    
108            public void trace(Throwable t) {
109                    _logger.log(_FQCN, Level.TRACE, null, t);
110            }
111    
112            public void trace(Object msg, Throwable t) {
113                    _logger.log(_FQCN, Level.TRACE, msg, t);
114            }
115    
116            public void warn(Object msg) {
117                    _logger.log(_FQCN, Level.WARN, msg, null);
118            }
119    
120            public void warn(Throwable t) {
121                    _logger.log(_FQCN, Level.WARN, null, t);
122            }
123    
124            public void warn(Object msg, Throwable t) {
125                    _logger.log(_FQCN, Level.WARN, msg, t);
126            }
127    
128            private static final String _FQCN = LogWrapper.class.getName();
129    
130            private Logger _logger;
131    
132    }