mirror of
https://github.com/saltbo/agent-kanban.git
synced 2026-09-19 09:01:47 +08:00
a2fa54a729
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.
45 lines
1.3 KiB
TypeScript
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),
|
|
};
|
|
}
|