15 lines
564 B
TypeScript
15 lines
564 B
TypeScript
import { app } from "electron";
|
|
import fs from "node:fs";
|
|
import path from "node:path";
|
|
|
|
export function logMain(event: string, detail: unknown = ""): void {
|
|
try {
|
|
const directory = path.join(app.getPath("userData"), "logs");
|
|
fs.mkdirSync(directory, { recursive: true });
|
|
const content = typeof detail === "string" ? detail : JSON.stringify(detail);
|
|
fs.appendFileSync(path.join(directory, "startup.log"), `${new Date().toISOString()} [${event}] ${content}\r\n`, "utf8");
|
|
} catch {
|
|
// Logging must never prevent the app from starting.
|
|
}
|
|
}
|