/* JFox, the OpenSource J2EE Application Server
 *
 * Copyright (C) 2002 huihoo.org
 * Distributable under GNU LGPL license
 * See the GNU Lesser General Public License for more details.
 */

package org.huihoo.jfox.logging;

import org.apache.log4j.Level;

/**
 * 
 * @author <a href="mailto:young_yy@hotmail.com">Young Yang</a>
 */

public class Logger {
  private org.apache.log4j.Logger logger;

  static {
    _init();
  }

  /**
   * set rootLogger
   */
  private static void _init() {
    LogManager.class.getName();
  }

  public static Logger getLogger(String name){
    return new Logger(name);
  }

  private Logger(String name){
    logger = org.apache.log4j.Logger.getLogger(name);
  }

  /**
   * <p> Log a message with debug log level. </p>
   *
   * @param message log this message
   */
  public void debug(Object message) {
    logger.log(Level.DEBUG,message);
  }


  /**
   * <p> Log an error with debug log level. </p>
   *
   * @param message log this message
   * @param t log this cause
   */
  public void debug(Object message, Throwable t) {
    logger.log(Level.DEBUG,message,t);
  }


  /**
   * <p> Log a message with info log level. </p>
   *
   * @param message log this message
   */
  public void info(Object message) {
    logger.log(Level.INFO,message);
  }


  /**
   * <p> Log an error with info log level. </p>
   *
   * @param message log this message
   * @param t log this cause
   */
  public void info(Object message, Throwable t) {
    logger.log(Level.INFO,message,t);
  }


  /**
   * <p> Log a message with warn log level. </p>
   *
   * @param message log this message
   */
  public void warn(Object message) {
    logger.log(Level.WARN,message);
  }


  /**
   * <p> Log an error with warn log level. </p>
   *
   * @param message log this message
   * @param t log this cause
   */
  public void warn(Object message, Throwable t) {
    logger.log(Level.WARN,message,t);
  }


  /**
   * <p> Log a message with error log level. </p>
   *
   * @param message log this message
   */
  public void error(Object message) {
    logger.log(Level.ERROR,message);
  }


  /**
   * <p> Log an error with error log level. </p>
   *
   * @param message log this message
   * @param t log this cause
   */
  public void error(Object message, Throwable t) {
    logger.log(Level.ERROR,message,t);
  }


  /**
   * <p> Log a message with fatal log level. </p>
   *
   * @param message log this message
   */
  public void fatal(Object message) {
    logger.log(Level.FATAL,message);
  }


  /**
   * <p> Log an error with fatal log level. </p>
   *
   * @param message log this message
   * @param t log this cause
   */
  public void fatal(Object message, Throwable t) {
    logger.log(Level.FATAL,message,t);
  }

  public static void main(String[] args) {
    Logger logger = Logger.getLogger("test");
    logger.info("test message");

  }

}
