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

📄 debug.java

📁 基于SSH (struts+spring+hibernate)框架设计的 CRM客户关系管理系统
💻 JAVA
字号:
package com.csu.crm.common;

/**
 * Classname    : Debug
 * Description  : 日志信息打印
 * Author       : li.haibo
 * Date         : 2007-07-12
 *
 * Last Update  : 2007-07-12
 * Author       : li.haibo
 * Version      : 1.0
 */


import java.util.logging.Logger;
import java.util.logging.Level;

/**
 * This class is just a helper class to make it handy
 * to print out debug statements
 */
public final class Debug {

    private static Logger logger = Logger.getLogger("com.nftelecom");

    /**
     * @param :msg 需要打印到控制台的信息
     * 
     */
    public static void print(String msg) {
        logger.log(Level.INFO, msg);
    }

    /**
     * @param :e 需要打印的例外 ,msg 需要打印到控制台的信息
     * 
     */
    public static void print(Exception e, String msg) {
        print( (Throwable) e, msg);
    }

    /**
     * @param :e 需要打印的例外
     * 
     */
    public static void print(Exception e) {
        print(e, null);
    }

    /**
     * @param :t 需要打印的例外 ,msg 需要打印到控制台的信息
     * 
     */
    public static void print(Throwable t, String msg) {
        logger.log(Level.WARNING, "Received throwable with Message: " + msg, t);
    }

    /**
     * @param :t 需要打印的例外
     * 
     */
    public static void print(Throwable t) {
        print(t, null);
    }

    //-----------------------------------------------------------------

    /**
     * @param :msg 需要打印到控制台的信息, obj 调用者的句柄
     *
     */
    public static void print(String msg, Object obj) {
        if(obj != null) {
            logger.log(Level.INFO, obj.toString() + ": " + msg);
        }
        else {
            logger.log(Level.INFO, "请把this指针传进来,如:Debug.print(msg, this)");
        }
    }

    /**
     * @param :e 需要打印的例外 ,msg 需要打印到控制台的信息, obj 调用者的句柄
     *
     */
    public static void print(Exception e, String msg, Object obj) {
        print((Throwable) e, msg, obj);
    }

    /**
     * @param :e 需要打印的例外, obj 调用者的句柄
     *
     */
    public static void print(Exception e, Object obj) {
        print(e, obj.toString(), obj);
    }

    /**
     * @param :t 需要打印的例外 ,msg 需要打印到控制台的信息, obj 调用者的句柄
     *
     */
    public static void print(Throwable t, String msg, Object obj) {
        logger.log(Level.WARNING, obj.toString() + ": " + msg, t);
    }

    /**
     * @param :t 需要打印的例外, obj 调用者的句柄
     *
     */
    public static void print(Throwable t, Object obj) {
        print(t, obj.toString(), obj);
    }

}

⌨️ 快捷键说明

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