loginfo.java

来自「用java开发的一些实用的短信通信模块其中包含MD5加密、http发送等信息」· Java 代码 · 共 73 行

JAVA
73
字号
package lib.commons.logging;

import java.util.Date;

import org.apache.commons.lang.exception.ExceptionUtils;
import org.apache.commons.lang.time.DateFormatUtils;

import lib.commons.Utils;

public class LogInfo {
	private String logName, logLevelName;

	private int logLevel;

	private boolean printStackTrace;

	private Object logMessage;

	private Throwable logThrowable;

	private Date logDate;

	public LogInfo(String logName, int logLevel, boolean printStackTrace,
			Object logMessage, Throwable logThrowable, Date logDate) {
		this.logName = logName;
		this.logLevel = logLevel;
		this.printStackTrace = printStackTrace;
		this.logMessage = logMessage;
		this.logThrowable = logThrowable;
		this.logDate = (null == logDate ? new Date() : logDate);
	}

	public String getLogName() {
		return null == logName ? Utils.EMPTY_STRING : logName;
	}

	public int getLogLevel() {
		return logLevel;
	}

	public String getLogLevelName() {
		if (null == logLevelName)
			logLevelName = LogLevel.getLevelName(logLevel);
		return logLevelName;
	}

	public boolean isPrintStackTrace() {
		return printStackTrace;
	}

	public Object getLogMessage() {
		return logMessage;
	}

	public Throwable getLogThrowable() {
		return logThrowable;
	}

	public String getLogThrowableString() {
		if (null == logThrowable)
			return null;
		return ExceptionUtils.getFullStackTrace(logThrowable);
	}

	public Date getLogDate() {
		return logDate;
	}

	public String getLogDateFormatString(String dateFormat) {
		return DateFormatUtils.format(logDate, dateFormat);
	}
}

⌨️ 快捷键说明

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