日志修改
This commit is contained in:
parent
e16d90d3c4
commit
02447a79a4
@ -9,6 +9,7 @@ import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -47,8 +48,9 @@ public class MemoryLogManager implements LoggerManager {
|
||||
log.info("当前请求ip:{}",ipAddr);
|
||||
log.info("当前用户id:{}",loginUserId);
|
||||
log.info("当前taskId:{}",loginUserId);
|
||||
List<SseEmitter> taskIdSSEList = taskIdSSEMap.getOrDefault(taskId, new ArrayList<>(1));
|
||||
List<SseEmitter> taskIdSSEList = taskIdSSEMap.computeIfAbsent(taskId, k->new ArrayList<>(1));
|
||||
taskIdSSEList.add(emitter);
|
||||
|
||||
return emitter;
|
||||
}
|
||||
|
||||
@ -88,6 +90,16 @@ public class MemoryLogManager implements LoggerManager {
|
||||
}
|
||||
}
|
||||
logCache.append(logContent);
|
||||
List<SseEmitter> sseEmitters = taskIdSSEMap.get(taskId);
|
||||
if (!CollectionUtils.isEmpty(sseEmitters)) {
|
||||
for (SseEmitter sseEmitter : sseEmitters) {
|
||||
try {
|
||||
sseEmitter.send(logContent);
|
||||
} catch (IOException e) {
|
||||
log.error("",e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
x
Reference in New Issue
Block a user