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

pro.shuangxi.devTool.utils.LogsUtils Maven / Gradle / Ivy

There is a newer version: 1.0.6
Show newest version
package pro.shuangxi.devTool.utils;

import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import pro.shuangxi.devTool.servlet.ServletSaveFilter;

/**
 * @author mengshx datetime 2024-08-19 11:42
 **/
@Component
public class LogsUtils {
    static ThreadLocal> threadLocal = new ThreadLocal();


    public static void doLog(List logs){
        for (String log : logs) {
            doLog(log);
        }
    }
    public static void doLog(String log){
        System.out.println(log);
        getLogs().add(log);
    }
    public static List getLogs() {
        return getLogs(true);
    }
    public static List getLogs(boolean isInit) {
        if (threadLocal.get() == null) {
            if(!isInit) return null;
            List logs = new ArrayList<>();
            threadLocal.set(logs);
            return logs;
        }
        return threadLocal.get();
    }
    public static void removeLogs() {
        threadLocal.remove();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy