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

📄 simplelogevent.java.svn-base

📁 日志组件,添加到应用中,可在数据库中查询日志
💻 SVN-BASE
字号:
package com.gisinfo.common.log.simple;

import com.gisinfo.common.log.LogEvent;
import com.gisinfo.common.log.Level;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * User: Ken
 * Date: 2008-5-22
 * Time: 11:30:56
 */

/**
 * LogEvent的一种默认实现,用于记录简单的日志。需要记录更详细的日志信息,请参考com.gisinfo.common.log.general.GeneralLogEvent。
 * 或继承LogEvent进行实现(推荐GeneralLogEvent不满足的情况下采用)
 */
public class SimpleLogEvent extends LogEvent {
    static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
    boolean showDetail = false;


    protected SimpleLogEvent(String description) {
        this.description = description;
    }

    protected SimpleLogEvent(String description, boolean showDetail) {
        this.description = description;
        this.showDetail = showDetail;
    }


    /*
   protected Logger logger = null;
   protected Level level = Level.DEBUG;  // 重要级别
   protected Date when;                   //什么时候
   protected String description;         //事件描述
    */
    //======Log:{level=debug date=2006-01-01 01:01:01 content=aabc}
    //======Log: debug  2006-01-01 01:01:01 aabbcc
    public String toString() {

        StringBuilder res = new StringBuilder()
                .append(sdf.format(this.when))
                .append("\t").append(this.level)
                .append("\t").append(this.description);
        if (showDetail && this.logger != null)
            res.append("\t[")
                    .append(this.getLogger().getSign())
                    .append("]");
        return res.toString();
    }
}

⌨️ 快捷键说明

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