fix: remove debug logs in production

This commit is contained in:
Nicolas Meienberger
2025-12-04 18:46:12 +01:00
parent 6b6338291b
commit 77f5886110
5 changed files with 9 additions and 8 deletions

View File

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

View File

@@ -2,12 +2,10 @@ import { type } from "arktype";
import "dotenv/config"; import "dotenv/config";
const envSchema = type({ const envSchema = type({
NODE_ENV: type.enumerated("development", "production", "test").default("development"), NODE_ENV: type.enumerated("development", "production", "test").default("production"),
SESSION_SECRET: "string?",
}).pipe((s) => ({ }).pipe((s) => ({
__prod__: s.NODE_ENV === "production", __prod__: s.NODE_ENV === "production",
environment: s.NODE_ENV, environment: s.NODE_ENV,
sessionSecret: s.SESSION_SECRET || "change-me-in-production-please",
})); }));
const parseConfig = (env: unknown) => { 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 { DATABASE_URL } from "../core/constants";
import * as schema from "./schema"; import * as schema from "./schema";
import fs from "node:fs/promises"; import fs from "node:fs/promises";
import { config } from "../core/config";
await fs.mkdir(path.dirname(DATABASE_URL), { recursive: true }); await fs.mkdir(path.dirname(DATABASE_URL), { recursive: true });
@@ -15,8 +16,7 @@ export const db = drizzle({ client: sqlite, schema });
export const runDbMigrations = () => { export const runDbMigrations = () => {
let migrationsFolder = path.join("/app", "assets", "migrations"); let migrationsFolder = path.join("/app", "assets", "migrations");
const { NODE_ENV } = process.env; if (!config.__prod__) {
if (NODE_ENV !== "production") {
migrationsFolder = path.join("/app", "app", "drizzle"); migrationsFolder = path.join("/app", "app", "drizzle");
} }

View File

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

View File

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