All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.afu.utils.common.FormatLogs Maven / Gradle / Ivy

There is a newer version: 0.0.55-RELEASE
Show newest version
package io.afu.utils.common;


import io.afu.utils.datetime.DateUtils;
import io.afu.utils.datetime.TimeUtils;
import org.apache.juli.logging.Log;
import org.apache.juli.logging.LogFactory;

/**
 * @author RffanLAB.方露宇
 * @version 0.1
 */
public class FormatLogs {

    private Log logger;

    public Log getLogger() {
        return logger;
    }

    public void setLogger(Log logger) {
        this.logger = logger;
    }

    /**
     * 生成实例
     * @param clazz 类名
     * @return 返回实例
     */
    public FormatLogs getInstant(Class clazz) {
        Log logger  = LogFactory.getLog(clazz);
        FormatLogs formatLogs = new FormatLogs();
        formatLogs.setLogger(logger);
        return formatLogs;
    }

    public void trace(String msg){
        makeMsg(msg);
        logger.trace(msg);
    }
    public void debug(String msg){
        StringBuilder stringBuilder = new StringBuilder();
        logger.debug(stringBuilder);
    }
    public void info(String msg){
        StringBuilder stringBuilder = new StringBuilder();
        logger.debug(stringBuilder);
    }
    public void warn(String msg){
        StringBuilder stringBuilder = new StringBuilder();
        logger.debug(stringBuilder);
    }
    public void error(String msg){
        StringBuilder stringBuilder = new StringBuilder();
        logger.debug(stringBuilder);
    }
    public void fatal(String msg){
        StringBuilder stringBuilder = new StringBuilder();
        logger.debug(stringBuilder);
    }
    public void off(String msg){
        StringBuilder stringBuilder = new StringBuilder();
        logger.debug(stringBuilder);
    }

    public String makeMsg(String msg) {
        String now = TimeUtils.getNow();
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append("[日志时间为]:");
        stringBuilder.append(now);
        stringBuilder.append(",");
        stringBuilder.append("[日志消息体]:");
        stringBuilder.append(msg);
        return stringBuilder.toString();
    }


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy