UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

31 lines (30 loc) • 1.44 kB
import { n as loggingState } from "./state-Bg-ugveB.mjs"; import { I as readLoggingConfig, r as redactLogRecordForTransport } from "./redact-Mj7pppxC.mjs"; import { n as formatTimestamp } from "./timestamps-CX4IhE2n.mjs"; import { stripVTControlCharacters } from "node:util"; //#region src/logging/json-console-line.ts function formatJsonConsoleLine(e) { const t = { ...e.meta, time: formatTimestamp(/* @__PURE__ */ new Date(), { style: "long" }), level: e.level, ...e.subsystem ? { subsystem: e.subsystem } : {}, message: e.message }; return JSON.stringify(redactLogRecordForTransport(t)); } /** Formats diagnostics that must bypass console capture without bypassing JSON console style. */ function formatConsoleDiagnosticLine(e) { return (loggingState.overrideSettings?.consoleStyle ?? readLoggingConfig()?.consoleStyle) === "json" ? formatJsonConsoleLine(e) : e.message; } /** Preserves human diagnostic blocks while serializing the whole block as one JSONL record. */ function formatConsoleDiagnosticBlock(e) { if ((loggingState.overrideSettings?.consoleStyle ?? readLoggingConfig()?.consoleStyle) !== "json") return e.message; const t = e.message.endsWith("\n") ? "\n" : ""; return `${formatJsonConsoleLine({ level: "error", message: stripVTControlCharacters(e.message).trimEnd() })}${t}`; } //#endregion export { formatConsoleDiagnosticLine as n, formatJsonConsoleLine as r, formatConsoleDiagnosticBlock as t };