package com.uas.account.entity;

import java.util.Date;

/**
 * 日志
 * 
 * @author yingp
 * 
 */
public class Log {

	public static final String defaultLogger = "sys";
	private String name;
	private Date logDate;
	// logLevel
	private String level;
	private String msg;
	private String detailMsg;
	private String key;

	public Log() {
		this.logDate = new Date();
		this.name = defaultLogger;
	}

	public Log(String name, String level, String key, String msg, Object detailMsg) {
		this();
		this.level = level;
		this.msg = msg;
		this.detailMsg = detailMsg != null ? detailMsg.toString() : null;
		this.name = name == null ? defaultLogger : name;
		this.key = key;
	}

	public static Log info(String msg) {
		return info(msg, null);
	}

	public static Log info(String msg, Object detailMsg) {
		return new Log(null, "INFO", null, msg, detailMsg);
	}

	public static Log info(String name, String msg, Object detailMsg) {
		return new Log(name, "INFO", null, msg, detailMsg);
	}

	public static Log info(String name, String key, String msg, Object detailMsg) {
		return new Log(name, "INFO", key, msg, detailMsg);
	}

	public static Log warn(String msg) {
		return warn(msg, null);
	}

	public static Log warn(String msg, Object detailMsg) {
		return new Log(null, "WARN", null, msg, detailMsg);
	}

	public static Log warn(String name, String msg, Object detailMsg) {
		return new Log(name, "WARN", null, msg, detailMsg);
	}

	public static Log warn(String name, String key, String msg, Object detailMsg) {
		return new Log(name, "WARN", key, msg, detailMsg);
	}

	public static Log error(String msg) {
		return error(msg, null);
	}

	public static Log error(String msg, Object detailMsg) {
		return new Log(null, "ERROR", null, msg, detailMsg);
	}

	public static Log error(String name, String msg, Object detailMsg) {
		return new Log(name, "ERROR", null, msg, detailMsg);
	}

	public static Log error(String name, String key, String msg, Object detailMsg) {
		return new Log(name, "ERROR", key, msg, detailMsg);
	}

	/**
	 * 记录时间
	 * 
	 * @return
	 */
	public Date getLogDate() {
		return logDate;
	}

	public void setLogDate(Date logDate) {
		this.logDate = logDate;
	}

	/**
	 * 错误级别：INFO、WARN、ERROR
	 * 
	 * @param level
	 */
	public String getLevel() {
		return level;
	}

	public void setLevel(String level) {
		this.level = level;
	}

	/**
	 * 日志消息
	 * 
	 * @return
	 */
	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	/**
	 * 详细情况
	 * 
	 * @return
	 */
	public String getDetailMsg() {
		return detailMsg;
	}

	public void setDetailMsg(String detailMsg) {
		this.detailMsg = detailMsg;
	}

	public String getKey() {
		return key;
	}

	public void setKey(String key) {
		this.key = key;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

}
