pro.shuangxi.devTool.utils.LogsUtils Maven / Gradle / Ivy
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