Add automatic log folder creation

This commit is contained in:
Jesse Wierzbinski 2024-03-13 07:28:12 -10:00
parent 626bc03dbd
commit 501b8bf78a
No known key found for this signature in database

View file

@ -6,6 +6,7 @@ import { client } from "~database/datasource";
import { LogLevel, LogManager, MultiLogManager } from "log-manager";
import { moduleIsEntry } from "@module";
import { createServer } from "~server";
import { exists, mkdir } from "fs/promises";
const timeAtStart = performance.now();
@ -21,6 +22,16 @@ const consoleLogger = new LogManager(
);
const dualLogger = new MultiLogManager([logger, consoleLogger]);
if (!(await exists(process.cwd() + "/logs/"))) {
await consoleLogger.log(
LogLevel.WARNING,
"Lysand",
`Creating logs directory at ${process.cwd()}/logs/`
);
await mkdir(process.cwd() + "/logs/");
}
await dualLogger.log(LogLevel.INFO, "Lysand", "Starting Lysand...");
// NODE_ENV seems to be broken and output `development` even when set to production, so use the flag instead