⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 defaultlogger.java

📁 这是一个mvc模式
💻 JAVA
字号:
package jsp.tags.dapact.util;
/**
 * Title:        Data Aware Processing And Control Tags
 * Description:  Tag library for the processing and controlling the input and output of data.
 * Copyright:    LGPL (http://www.gnu.org/copyleft/lesser.html)
 * Compile Date: @compile_date@      
 * @author Allen M Servedio
 * @amp_sign@version @VERSION@
 */

/**
 * Default implementation of the logger interface - just logs everything to system out
 * or system error.
 */
public class DefaultLogger implements LoggerInf
{

  public DefaultLogger()
  {
  }

  /**
   * Log a Throwable - since no type is specified, this should be considered an error.
   *
   * @param e the Throwable to log.
   */
  public void log(Throwable e)
  {
    System.err.print(LazyDate.getInstance().todaysDateWithSpace());
    e.printStackTrace(System.err);
  }

  /**
   * Log a message - since no type is specified, this should be considered info.
   *
   * @param msg a message to log.
   */
  public void log(String msg)
  {
    System.out.print(LazyDate.getInstance().todaysDateWithSpace());
    System.out.println(msg);
  }

  /**
   * Log a Throwable with an extra message - since no type is specified, this should be considered an error.
   *
   * @param msg an extra message to include with the Throwable.
   * @param e the Throwable to log.
   */
  public void log(String msg, Throwable e)
  {
    System.err.print(LazyDate.getInstance().todaysDateWithSpace());
    System.err.println(msg);
    e.printStackTrace(System.err);
  }

  /**
   * Log a Throwable with a log type.
   *
   * @param type one of the log types specified in the LogTypes interface.
   * @param e the Throwable to log.
   */
  public void log(int type, Throwable e)
  {
    switch (type)
    {
      case LoggerInf.LogTypes.ERROR:
        System.err.print(LazyDate.getInstance().todaysDateWithSpace());
        e.printStackTrace(System.err);
      break;
      default:
        System.out.print(LazyDate.getInstance().todaysDateWithSpace());
        e.printStackTrace(System.out);
      break;
    }
  }

  /**
   * Log a Throwable with an extra message.
   *
   * @param type one of the log types specified in the LogTypes interface.
   * @param msg an extra message to include with the Throwable.
   * @param e the Throwable to log.
   */
  public void log(int type, String msg, Throwable e)
  {
    switch (type)
    {
      case LoggerInf.LogTypes.ERROR:
        System.err.print(LazyDate.getInstance().todaysDateWithSpace());
        System.err.println(msg);
        e.printStackTrace(System.err);
      break;
      default:
        System.out.print(LazyDate.getInstance().todaysDateWithSpace());
        System.out.println(msg);
        e.printStackTrace(System.out);
      break;
    }
  }

  /**
   * Log a message.
   *
   * @param type one of the log types specified in the LogTypes interface.
   * @param msg an extra message to include with the Throwable.
   */
  public void log(int type, String msg)
  {
    switch (type)
    {
      case LoggerInf.LogTypes.ERROR:
        System.err.print(LazyDate.getInstance().todaysDateWithSpace());
        System.err.println(msg);
      break;
      default:
        System.out.print(LazyDate.getInstance().todaysDateWithSpace());
        System.out.println(msg);
      break;
    }
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -