diff --git a/packages/web_ui/src/components/LogConsole.tsx b/packages/web_ui/src/components/LogConsole.tsx index c327d4ec..5db8da63 100644 --- a/packages/web_ui/src/components/LogConsole.tsx +++ b/packages/web_ui/src/components/LogConsole.tsx @@ -68,6 +68,24 @@ function formatLog(info: Info, key: number): ReactElement { return [{level}] {info.message}
; } +/** + * Test if a log entry survives the console's actions only filter + */ +function passesActionsOnly(info: Info) { + // Clusterio's own entries are bookkeeping, only keep those reporting a problem. + if (info.level !== "server") { + return lib.levels[info.level] <= lib.levels.warn; + } + + // Factorio's seconds stamped engine log is verbose diagnostics, only keep warnings and errors. + if (info.parsed?.format === "seconds") { + return info.parsed.level === "Warning" || info.parsed.level === "Error"; + } + + // What is left is the date stamped console log: the actions done to the server and the replies to them. + return true; +} + type LogConsoleProps = { all?: boolean; controller?: boolean; @@ -159,11 +177,7 @@ export default function LogConsole(props: LogConsoleProps) { "desc", )).then(result => { setPastLines(result.log - .filter(info => ( - !props.actionsOnly - || (info as Info).level !== "server" - || (info as Info).parsed?.type === "action" - )) + .filter(info => !props.actionsOnly || passesActionsOnly(info as Info)) .map((info, index) => formatLog(info as Info, -index - 1)) .reverse() ); @@ -175,7 +189,7 @@ export default function LogConsole(props: LogConsoleProps) { } function logHandler(info: Info) { - if (!props.actionsOnly || info.level !== "server" || info.parsed?.type === "action") { + if (!props.actionsOnly || passesActionsOnly(info)) { setLines(currentLines => currentLines.concat( [formatLog(info, currentLines.length)] ));