Files
openclaw/src/logging/config.ts
Mikhail Beliakov fd934a566b feat(cli): add json schema to cli tool (#54523)
Merged via squash.

Prepared head SHA: 39c15ee70d
Co-authored-by: kvokka <15954013+kvokka@users.noreply.github.com>
Co-authored-by: altaywtf <9790196+altaywtf@users.noreply.github.com>
Reviewed-by: @altaywtf
2026-03-26 02:30:32 +03:00

26 lines
840 B
TypeScript

import { getCommandPathWithRootOptions } from "../cli/argv.js";
import { loadConfig, type OpenClawConfig } from "../config/config.js";
type LoggingConfig = OpenClawConfig["logging"];
export function shouldSkipMutatingLoggingConfigRead(argv: string[] = process.argv): boolean {
const [primary, secondary] = getCommandPathWithRootOptions(argv, 2);
return primary === "config" && (secondary === "schema" || secondary === "validate");
}
export function readLoggingConfig(): LoggingConfig | undefined {
if (shouldSkipMutatingLoggingConfigRead()) {
return undefined;
}
try {
const parsed = loadConfig();
const logging = parsed?.logging;
if (!logging || typeof logging !== "object" || Array.isArray(logging)) {
return undefined;
}
return logging as LoggingConfig;
} catch {
return undefined;
}
}