openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
70 lines (69 loc) • 1.91 kB
JavaScript
import { a as getLogger } from "./logger-kwZIqwuw.js";
import { d as warn, n as info, o as logVerboseConsole, t as danger, u as success } from "./globals-DBUMOBZ8.js";
import { m as defaultRuntime, t as createSubsystemLogger } from "./subsystem-DISldKSB.js";
//#region src/logger.ts
const subsystemPrefixRe = /^([a-z][a-z0-9-]{1,20}):\s+(.*)$/i;
function splitSubsystem(message) {
const match = message.match(subsystemPrefixRe);
if (!match) return null;
const [, subsystem, rest] = match;
return {
subsystem,
rest
};
}
function logWithSubsystem(params) {
const parsed = params.runtime === defaultRuntime ? splitSubsystem(params.message) : null;
if (parsed) {
createSubsystemLogger(parsed.subsystem)[params.subsystemMethod](parsed.rest);
return;
}
params.runtime[params.runtimeMethod](params.runtimeFormatter(params.message));
getLogger()[params.loggerMethod](params.message);
}
function logInfo(message, runtime = defaultRuntime) {
logWithSubsystem({
message,
runtime,
runtimeMethod: "log",
runtimeFormatter: info,
loggerMethod: "info",
subsystemMethod: "info"
});
}
function logWarn(message, runtime = defaultRuntime) {
logWithSubsystem({
message,
runtime,
runtimeMethod: "log",
runtimeFormatter: warn,
loggerMethod: "warn",
subsystemMethod: "warn"
});
}
function logSuccess(message, runtime = defaultRuntime) {
logWithSubsystem({
message,
runtime,
runtimeMethod: "log",
runtimeFormatter: success,
loggerMethod: "info",
subsystemMethod: "info"
});
}
function logError(message, runtime = defaultRuntime) {
logWithSubsystem({
message,
runtime,
runtimeMethod: "error",
runtimeFormatter: danger,
loggerMethod: "error",
subsystemMethod: "error"
});
}
function logDebug(message) {
getLogger().debug(message);
logVerboseConsole(message);
}
//#endregion
export { logWarn as a, logSuccess as i, logError as n, logInfo as r, logDebug as t };