    001    /*
    002     * Licensed to the Apache Software Foundation (ASF) under one or more
    003     * contributor license agreements. See the NOTICE file distributed with
    004     * this work for additional information regarding copyright ownership.
    005     * The ASF licenses this file to You under the Apache license, Version 2.0
    006     * (the "License"); you may not use this file except in compliance with
    007     * the License. You may obtain a copy of the License at
    008     *
    009     *      http://www.apache.org/licenses/LICENSE-2.0
    010     *
    011     * Unless required by applicable law or agreed to in writing, software
    012     * distributed under the License is distributed on an "AS IS" BASIS,
    013     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    014     * See the license for the specific language governing permissions and
    015     * limitations under the license.
    016     */
    017    package org.apache.logging.log4j.jcl;
    018
    019    import java.io.Serializable;
    020
    021    import org.apache.commons.logging.Log;
    022    import org.apache.logging.log4j.Level;
    023    import org.apache.logging.log4j.spi.ExtendedLogger;
    024
    025    /**
    026     *
    027     */
    028    public class Log4jLog implements Log, Serializable {
    029
    030        private static final long serialVersionUID = 1L;
    031        private static final String FQCN = Log4jLog.class.getName();
    032
    033        private final ExtendedLogger logger;
    034
    035        public Log4jLog(final ExtendedLogger logger) {
    036            this.logger = logger;
    037        }
    038
    039        @Override
    040        public boolean isDebugEnabled() {
    041            return logger.isEnabled(Level.DEBUG, null, null);
    042        }
    043
    044        @Override
    045        public boolean isErrorEnabled() {
    046            return logger.isEnabled(Level.ERROR, null, null);
    047        }
    048
    049        @Override
    050        public boolean isFatalEnabled() {
    051            return logger.isEnabled(Level.FATAL, null, null);
    052        }
    053
    054        @Override
    055        public boolean isInfoEnabled() {
    056            return logger.isEnabled(Level.INFO, null, null);
    057        }
    058
    059        @Override
    060        public boolean isTraceEnabled() {
    061            return logger.isEnabled(Level.TRACE, null, null);
    062        }
    063
    064        @Override
    065        public boolean isWarnEnabled() {
    066            return logger.isEnabled(Level.WARN, null, null);
    067        }
    068
    069        @Override
    070        public void trace(final Object message) {
    071            logger.logIfEnabled(FQCN, Level.TRACE, null, message, null);
    072        }
    073
    074        @Override
    075        public void trace(final Object message, final Throwable t) {
    076            logger.logIfEnabled(FQCN, Level.TRACE, null, message, t);
    077        }
    078
    079        @Override
    080        public void debug(final Object message) {
    081            logger.logIfEnabled(FQCN, Level.DEBUG, null, message, null);
    082        }
    083
    084        @Override
    085        public void debug(final Object message, final Throwable t) {
    086            logger.logIfEnabled(FQCN, Level.DEBUG, null, message, t);
    087        }
    088
    089        @Override
    090        public void info(final Object message) {
    091            logger.logIfEnabled(FQCN, Level.INFO, null, message, null);
    092        }
    093
    094        @Override
    095        public void info(final Object message, final Throwable t) {
    096            logger.logIfEnabled(FQCN, Level.INFO, null, message, t);
    097        }
    098
    099        @Override
    100        public void warn(final Object message) {
    101            logger.logIfEnabled(FQCN, Level.WARN, null, message, null);
    102        }
    103
    104        @Override
    105        public void warn(final Object message, final Throwable t) {
    106            logger.logIfEnabled(FQCN, Level.WARN, null, message, t);
    107        }
    108
    109        @Override
    110        public void error(final Object message) {
    111            logger.logIfEnabled(FQCN, Level.ERROR, null, message, null);
    112        }
    113
    114        @Override
    115        public void error(final Object message, final Throwable t) {
    116            logger.logIfEnabled(FQCN, Level.ERROR, null, message, t);
    117        }
    118
    119        @Override
    120        public void fatal(final Object message) {
    121            logger.logIfEnabled(FQCN, Level.FATAL, null, message, null);
    122        }
    123
    124        @Override
    125        public void fatal(final Object message, final Throwable t) {
    126            logger.logIfEnabled(FQCN, Level.FATAL, null, message, t);
    127        }
    128    }