diff --git a/.env.example b/.env.example index 084b871b..4a74a6b4 100644 --- a/.env.example +++ b/.env.example @@ -43,4 +43,7 @@ POSTMARK_TOKEN= # for custom drawio server DRAWIO_URL= -DISABLE_TELEMETRY=false \ No newline at end of file +DISABLE_TELEMETRY=false + +# Enable debug logging in production (default: false) +DEBUG_MODE=false \ No newline at end of file diff --git a/apps/server/src/common/logger/internal-log-filter.ts b/apps/server/src/common/logger/internal-log-filter.ts index f56d3fce..5273716c 100644 --- a/apps/server/src/common/logger/internal-log-filter.ts +++ b/apps/server/src/common/logger/internal-log-filter.ts @@ -12,10 +12,14 @@ export class InternalLogFilter extends ConsoleLogger { constructor() { super(); - this.allowedLogLevels = - process.env.NODE_ENV === 'production' - ? ['log', 'error', 'fatal'] - : ['log', 'debug', 'verbose', 'warn', 'error', 'fatal']; + const isProduction = process.env.NODE_ENV === 'production'; + const isDebugMode = process.env.DEBUG_MODE === 'true'; + + if (isProduction && !isDebugMode) { + this.allowedLogLevels = ['log', 'error', 'fatal']; + } else { + this.allowedLogLevels = ['log', 'debug', 'verbose', 'warn', 'error', 'fatal']; + } } private isLogLevelAllowed(level: string): boolean {