mirror of
https://github.com/Pandipipas/scoreko-electron-dev.git
synced 2026-06-06 05:32:06 +00:00
feat: complete pending roadmap items with doctor, hardening, and code quality
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
export type LogLevel = "debug" | "info" | "warn" | "error";
|
||||
|
||||
type LogContext = Record<string, unknown>;
|
||||
|
||||
function write(level: LogLevel, message: string, context?: LogContext): void {
|
||||
const payload = {
|
||||
ts: new Date().toISOString(),
|
||||
level,
|
||||
source: "scoreko-electron",
|
||||
message,
|
||||
...(context ? { context } : {}),
|
||||
};
|
||||
|
||||
const line = JSON.stringify(payload);
|
||||
|
||||
if (level === "error") {
|
||||
console.error(line);
|
||||
return;
|
||||
}
|
||||
|
||||
if (level === "warn") {
|
||||
console.warn(line);
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(line);
|
||||
}
|
||||
|
||||
export const logger = {
|
||||
debug: (message: string, context?: LogContext): void => write("debug", message, context),
|
||||
info: (message: string, context?: LogContext): void => write("info", message, context),
|
||||
warn: (message: string, context?: LogContext): void => write("warn", message, context),
|
||||
error: (message: string, context?: LogContext): void => write("error", message, context),
|
||||
};
|
||||
Reference in New Issue
Block a user