io.afu.utils.common.FormatLogs Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of utils Show documentation
Show all versions of utils Show documentation
RffanLAB Utils For Many Way use
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();
}
}