mirror of
https://github.com/Pandipipas/scoreko-electron-dev.git
synced 2026-06-05 21:22:07 +00:00
e3d3936156
- Added bootstrap functionality to initialize the Electron application. - Created a new paths module to manage application paths and URLs. - Introduced a shutdown service to handle graceful application shutdowns. - Refactored error logging to use a dedicated logger module. - Implemented process killing logic for NodeCG processes across platforms. - Established navigation policies for internal and external URL handling in windows. - Developed window service for creating and managing application windows. - Added tests for application paths, application controller, navigation policies, process killer, and shutdown service.
35 lines
929 B
TypeScript
35 lines
929 B
TypeScript
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),
|
|
};
|