Files
saltbo__agent-kanban/server/observability/logger.ts
jarvis a2fa54a729 feat!: rebuild Agent Kanban for Realmroot Toolbox
Replace the v1 Agent/Machine runtime and CLI architecture with the v2 Resource Server, AMA-backed projections, task lifecycle, session observation, BDD specifications, and a single-package layered codebase.

BREAKING CHANGE: remove the v1 CLI, internal Agent/Machine runtime entities, workspace layout, and legacy runtime coordination APIs.
2026-09-02 00:17:52 -04:00

45 lines
1.3 KiB
TypeScript

type LogLevel = "debug" | "info" | "warn" | "error" | "fatal";
const LEVEL_VALUES: Record<LogLevel, number> = {
debug: 20,
info: 30,
warn: 40,
error: 50,
fatal: 60,
};
export interface Logger {
debug: (msg: string, fields?: Record<string, unknown>) => void;
info: (msg: string, fields?: Record<string, unknown>) => void;
warn: (msg: string, fields?: Record<string, unknown>) => void;
error: (msg: string, fields?: Record<string, unknown>) => void;
fatal: (msg: string, fields?: Record<string, unknown>) => void;
}
export function createLogger(module: string): Logger {
const write = (level: LogLevel, msg: string, fields?: Record<string, unknown>) => {
const entry = JSON.stringify({
...fields,
level: LEVEL_VALUES[level],
time: new Date().toISOString(),
name: module,
msg,
});
if (level === "error" || level === "fatal") {
console.error(entry);
} else if (level === "warn") {
console.warn(entry);
} else {
console.log(entry);
}
};
return {
debug: (msg, fields) => write("debug", msg, fields),
info: (msg, fields) => write("info", msg, fields),
warn: (msg, fields) => write("warn", msg, fields),
error: (msg, fields) => write("error", msg, fields),
fatal: (msg, fields) => write("fatal", msg, fields),
};
}