mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-03 01:16:24 +00:00
Log structured details when Discord persistent component registry state falls back after a store failure. - Format Error name, message, stack, and cause metadata at the Discord registry warning call site. - Forward plugin runtime logger metadata to the underlying child logger. - Add focused regression coverage for the Discord fallback warning and runtime logging adapter. - Add changelog credit for @100menotu001. Fixes #84185. Co-authored-by: OpenClaw Contributor <100menotu001@users.noreply.github.com> Co-authored-by: Craig <froelich@craigs.mac.studio.froho>
38 lines
1.2 KiB
TypeScript
38 lines
1.2 KiB
TypeScript
import { shouldLogVerbose } from "../../globals.js";
|
|
import { getChildLogger } from "../../logging.js";
|
|
import { normalizeLogLevel } from "../../logging/levels.js";
|
|
import type { PluginRuntime } from "./types.js";
|
|
|
|
function writeRuntimeLog(
|
|
log: (...args: unknown[]) => void,
|
|
message: string,
|
|
meta?: Record<string, unknown>,
|
|
): void {
|
|
if (meta && Object.keys(meta).length > 0) {
|
|
log(meta, message);
|
|
return;
|
|
}
|
|
log(message);
|
|
}
|
|
|
|
export function createRuntimeLogging(): PluginRuntime["logging"] {
|
|
return {
|
|
shouldLogVerbose,
|
|
getChildLogger: (bindings, opts) => {
|
|
const logger = getChildLogger(bindings, {
|
|
level: opts?.level ? normalizeLogLevel(opts.level) : undefined,
|
|
});
|
|
return {
|
|
debug: (message, meta) => {
|
|
if (logger.debug) {
|
|
writeRuntimeLog(logger.debug.bind(logger), message, meta);
|
|
}
|
|
},
|
|
info: (message, meta) => writeRuntimeLog(logger.info.bind(logger), message, meta),
|
|
warn: (message, meta) => writeRuntimeLog(logger.warn.bind(logger), message, meta),
|
|
error: (message, meta) => writeRuntimeLog(logger.error.bind(logger), message, meta),
|
|
};
|
|
},
|
|
};
|
|
}
|