epgtools.loggerfactory.LoggerFactory.java Source code

Java tutorial

Introduction

Here is the source code for epgtools.loggerfactory.LoggerFactory.java

Source

/*
 * Copyright (C) 2016 normal
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package epgtools.loggerfactory;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.commons.logging.impl.NoOpLog;

/**
 * ???????????<br>
 * outLog=false???????????<br>
 *
 * @author normal
 */
public final class LoggerFactory {

    private final Class<?> myClass;
    private final boolean outLog;
    private final Log THIS_LOG = LogFactory.getLog(LoggerFactory.class);

    public LoggerFactory(Class<?> myClass, boolean outLog) {
        this.myClass = myClass;
        this.outLog = outLog;
    }

    public Log getLOG() {
        final Log LOG;
        if (this.outLog) {
            LOG = LogFactory.getLog(myClass);
        } else {
            LOG = new NoOpLog();
            THIS_LOG.info(myClass + "????");
        }
        return LOG;
    }

    public boolean isOutLog() {
        return outLog;
    }

}