fix: remove debug logs in production

This commit is contained in:
Nicolas Meienberger
2025-12-04 18:46:12 +01:00
parent 08d8a47352
commit 0f7bd1e042
5 changed files with 9 additions and 8 deletions

View File

@@ -14,7 +14,7 @@ WORKDIR /deps
ARG TARGETARCH
ARG RESTIC_VERSION="0.18.1"
ARG SHOUTRRR_VERSION="0.12.0"
ARG SHOUTRRR_VERSION="0.12.1"
ENV TARGETARCH=${TARGETARCH}
RUN apk add --no-cache curl bzip2 unzip tar

View File

@@ -2,12 +2,10 @@ import { type } from "arktype";
import "dotenv/config";
const envSchema = type({
NODE_ENV: type.enumerated("development", "production", "test").default("development"),
SESSION_SECRET: "string?",
NODE_ENV: type.enumerated("development", "production", "test").default("production"),
}).pipe((s) => ({
__prod__: s.NODE_ENV === "production",
environment: s.NODE_ENV,
sessionSecret: s.SESSION_SECRET || "change-me-in-production-please",
}));
const parseConfig = (env: unknown) => {

View File

@@ -6,6 +6,7 @@ import { migrate } from "drizzle-orm/bun-sqlite/migrator";
import { DATABASE_URL } from "../core/constants";
import * as schema from "./schema";
import fs from "node:fs/promises";
import { config } from "../core/config";
await fs.mkdir(path.dirname(DATABASE_URL), { recursive: true });
@@ -15,8 +16,7 @@ export const db = drizzle({ client: sqlite, schema });
export const runDbMigrations = () => {
let migrationsFolder = path.join("/app", "assets", "migrations");
const { NODE_ENV } = process.env;
if (NODE_ENV !== "production") {
if (!config.__prod__) {
migrationsFolder = path.join("/app", "app", "drizzle");
}

View File

@@ -1,15 +1,17 @@
import { createLogger, format, transports } from "winston";
import { sanitizeSensitiveData } from "./sanitize";
import { config } from "../core/config";
const { printf, combine, colorize } = format;
const printConsole = printf((info) => `${info.level} > ${info.message}`);
const consoleFormat = combine(colorize(), printConsole);
const defaultLevel = config.__prod__ ? "info" : "debug";
const winstonLogger = createLogger({
level: "debug",
level: process.env.LOG_LEVEL || defaultLevel,
format: format.json(),
transports: [new transports.Console({ level: "debug", format: consoleFormat })],
transports: [new transports.Console({ level: process.env.LOG_LEVEL || defaultLevel, format: consoleFormat })],
});
const log = (level: "info" | "warn" | "error" | "debug", messages: unknown[]) => {

View File

@@ -41,3 +41,4 @@ services:
- /var/lib/zerobyte:/var/lib/zerobyte:rshared
- /run/docker/plugins:/run/docker/plugins
- /var/run/docker.sock:/var/run/docker.sock
- ~/.config/rclone:/root/.config/rclone