feat: enhance log filtering by adding support for debug level and updating log hierarchy #4293

This commit is contained in:
Tunglies
2025-08-06 20:49:54 +08:00
parent 7b976c16eb
commit a9cfb2cfaa
4 changed files with 36 additions and 11 deletions

View File

@@ -29,6 +29,9 @@ const Item = styled(Box)(({ theme: { palette, typography } }) => ({
'& .type[data-type="info"], & .type[data-type="inf"]': {
color: palette.info.main,
},
'& .type[data-type="debug"], & .type[data-type="dbg"]': {
color: palette.text.secondary,
},
"& .data": {
color: palette.text.primary,
overflowWrap: "anywhere",

View File

@@ -30,7 +30,7 @@ const LOG_LEVEL_HIERARCHY = {
info: ["info", "warning", "error"],
warning: ["warning", "error"],
error: ["error"],
debug: ["debug"],
debug: ["info", "warning", "error", "debug"],
};
const LogPage = () => {

View File

@@ -185,10 +185,7 @@ export const clearGlobalLogs = () => {
export const useGlobalLogData = (logLevel: LogLevel = "all") => {
const logs = useGlobalLogStore((state) => state.logs);
// 根据当前选择的日志等级过滤日志
if (logLevel === "all") {
return logs;
} else {
return logs.filter((log) => log.type.toLowerCase() === logLevel);
}
// 日志已经在后端根据级别进行了过滤,这里直接返回所有日志
// 不需要在前端再次过滤避免重复过滤导致DEBUG日志丢失
return logs;
};