package com.engine.htxc.commonutil.log;

import cn.hutool.core.date.DateTime;
import org.apache.log4j.Logger;
import weaver.general.BaseBean;

/**
 * <p>log日志输出</p>
 * @author K1810015
 * @version 1.0.0
 * @ClassName CustomizeLog.java
 * @createTime 2022年07月15日 10:49:00
 */
public class CustomizeLog {

    private CustomizeLog() {

    }

    public static void printLog(String value){
        BaseBean bs =new BaseBean();
        try {
            Throwable throwable = new Throwable();
            String classname = throwable.getStackTrace()[1].getClassName();
            String methoadname = throwable.getStackTrace()[1].getMethodName();
            String datetime=DateTime.now().toString("yyyy-MM-dd hh:mm:ss");
            String logvalue=classname+"["+methoadname+"]"+":"+datetime+" "+value;
            bs.writeLog(logvalue);
            Logger.getLogger(CustomizeLog.class.getName()).info(logvalue);

        }catch (Exception e){
            /**
             * @remark 没必要记录这场而异常错误
             */
            bs.writeLog(value);
        }
    }
}
