Package net.sourceforge.javautil.common.logging

Source Code of net.sourceforge.javautil.common.logging.LoggerAbstract

package net.sourceforge.javautil.common.logging;

import java.io.Writer;

import net.sourceforge.javautil.common.ThrowableUtil;
import net.sourceforge.javautil.common.logging.ILoggerLevel;
import net.sourceforge.javautil.common.logging.LoggerLevelStandard;
import net.sourceforge.javautil.common.logging.LoggerWriter;
import net.sourceforge.javautil.common.logging.ILoggingFramework;

/**
* The logger wrapper for the JDK logging framework.
*
* @author elponderador
* @author $Author$
* @version $Id$
*/
public abstract class LoggerAbstract<F extends ILoggingFramework> implements ILogger {
 
  protected final F framework;
 
  public LoggerAbstract(F framework) {
    this.framework = framework;
  }

  public F getFramework() { return framework; }

  public Writer getLoggingWriter(ILoggerLevel level) {
    return new LoggerWriter(this, level);
  }

  public boolean isLogging(ILoggerLevel level) {
    switch (level.getBasicType()) {
      case DEBUG: return isDebug();
      case INFO: return isInfo();
      case WARN: return isWarn();
      case ERROR: return isError();
      case FATAL: return isFatal();
      case ALL: return isLogging();
      case OFF: return !isLogging();
    }
    return false;
  }

  public void debug(String message, Throwable throwable) {
    this.log(LoggerLevelStandard.DEBUG, message, throwable);
  }

  public void debug(String message) {
    this.log(LoggerLevelStandard.DEBUG, message);
  }

  public void error(String message, Throwable throwable) {
    this.log(LoggerLevelStandard.FATAL, message, throwable);
  }

  public void error(String message) {
    this.log(LoggerLevelStandard.FATAL, message);
  }

  public void fatal(String message, Throwable throwable) {
    this.log(LoggerLevelStandard.FATAL, message, throwable);
  }

  public void fatal(String message) {
    this.log(LoggerLevelStandard.FATAL, message);
  }

  public void info(String message, Throwable throwable) {
    this.log(LoggerLevelStandard.INFO, message, throwable);
  }

  public void info(String message) {
    this.log(LoggerLevelStandard.INFO, message);
  }

  public void warn(String message, Throwable throwable) {
    this.log(LoggerLevelStandard.WARN, message, throwable);
  }

  public void warn(String message) {
    this.log(LoggerLevelStandard.WARN, message);
  }
 
}
TOP

Related Classes of net.sourceforge.javautil.common.logging.LoggerAbstract

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.