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

com.luues.util.logs.LogUtil Maven / Gradle / Ivy

There is a newer version: 1.3.0.5.RELEASE
Show newest version
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);
            }
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy