com.luues.util.logs.LogUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of commons-util Show documentation
Show all versions of commons-util Show documentation
A Simple Tool Operations Class
package com.luues.util.logs;
import lombok.extern.slf4j.Slf4j;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/**
* 记录sql日志
* 只需在方法上加SqlAnnotation注解
*/
@Slf4j
public class LogUtil {
protected static ExecutorService singleThreadExecutor = Executors.newSingleThreadExecutor();
public static boolean isInfoEnabled(){
return log.isInfoEnabled();
}
public static boolean isDebugEnabled(){
return log.isDebugEnabled();
}
public static boolean isErrorEnabled(){
return log.isErrorEnabled();
}
public static boolean isTraceEnabled(){
return log.isTraceEnabled();
}
public static boolean isWarnEnabled(){
return log.isWarnEnabled();
}
public static void error(String msg){
singleThreadExecutor.execute(new Runnable() {
public void run() {
log.error(msg);
}
});
}
public static void error(String msg, Object ...msgs){
singleThreadExecutor.execute(new Runnable() {
public void run() {
log.error(msg, msgs);
}
});
}
public static void info(String msg){
singleThreadExecutor.execute(new Runnable() {
public void run() {
log.info(msg);
}
});
}
public static void info(String[] strings){
singleThreadExecutor.execute(new Runnable() {
public void run() {
for(String string : strings)
log.info(string);
}
});
}
public static void info(String msg, Object ...msgs){
singleThreadExecutor.execute(new Runnable() {
public void run() {
log.info(msg, msgs);
}
});
}
public static void debug(String msg){
singleThreadExecutor.execute(new Runnable() {
public void run() {
log.debug(msg);
}
});
}
public static void debug(String msg, Object... msgs){
singleThreadExecutor.execute(new Runnable() {
public void run() {
log.debug(msg, msgs);
}
});
}
public static void warn(String msg){
singleThreadExecutor.execute(new Runnable() {
public void run() {
log.warn(msg);
}
});
}
public static void warn(String msg, Object... msgs){
singleThreadExecutor.execute(new Runnable() {
public void run() {
log.warn(msg, msgs);
}
});
}
}