Skip to content

Commit

Permalink
Check if log directory exists
Browse files Browse the repository at this point in the history
  • Loading branch information
twobiers committed Jan 21, 2025
1 parent 04ff7d6 commit 066be2f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/utils/logger.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { mkdir } from "node:fs/promises";
import { mkdir, exists } from "node:fs/promises";

import { pino, type LoggerOptions } from "pino";

Expand All @@ -9,7 +9,9 @@ const logDir = "logs";

const usesLogDir = nodeEnv === "production";
if (usesLogDir) {
await mkdir(logDir, { recursive: true });
if (!(await exists(logDir))) {
await mkdir(logDir, { recursive: true });
}
}

const loggingConfigs = {
Expand Down

0 comments on commit 066be2f

Please sign in to comment.