perf(logging): skip config/fs work in default silent test path

This commit is contained in:
Peter Steinberger
2026-03-02 18:41:08 +00:00
parent 5c1eb071ca
commit 842087319b
4 changed files with 121 additions and 7 deletions

View File

@@ -58,6 +58,19 @@ function normalizeConsoleStyle(style?: string): ConsoleStyle {
}
function resolveConsoleSettings(): ConsoleSettings {
const envLevel = resolveEnvLogLevelOverride();
// Test runs default to silent console logging unless explicitly overridden.
// Skip config-file and full config fallback reads in this fast path.
if (
process.env.VITEST === "true" &&
process.env.OPENCLAW_TEST_CONSOLE !== "1" &&
!isVerbose() &&
!envLevel &&
!loggingState.overrideSettings
) {
return { level: "silent", style: normalizeConsoleStyle(undefined) };
}
let cfg: OpenClawConfig["logging"] | undefined =
(loggingState.overrideSettings as LoggerSettings | null) ?? readLoggingConfig();
if (!cfg) {
@@ -72,7 +85,6 @@ function resolveConsoleSettings(): ConsoleSettings {
}
}
}
const envLevel = resolveEnvLogLevelOverride();
const level = envLevel ?? normalizeConsoleLevel(cfg?.consoleLevel);
const style = normalizeConsoleStyle(cfg?.consoleStyle);
return { level, style };