From 7b6aa3ba5a720a893d22bbc558137f9b0fd6bb5b Mon Sep 17 00:00:00 2001 From: Lars Kiesow Date: Sun, 19 Nov 2023 21:00:54 +0100 Subject: [PATCH] Allow enabling dev logs This patch allows users to enable dev logs on production systems by setting the `HIDE_DEV_LOGS` environment variable. Before, you could only use this on a non-production environment. On production, the logs would be disabled. This patch changes the behavior and uses the `NODE_ENV` only as default. On production they are disabled if `HIDE_DEV_LOGS` is undefined but can be enabled by setting `HIDE_DEV_LOGS=0` on dev, they are enabled if undefined, but can be disabled by setting `HIDE_DEV_LOGS=1`. --- server/Logger.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/Logger.js b/server/Logger.js index 19e657b4..9909778f 100644 --- a/server/Logger.js +++ b/server/Logger.js @@ -5,6 +5,7 @@ class Logger { constructor() { this.isDev = process.env.NODE_ENV !== 'production' this.logLevel = !this.isDev ? LogLevel.INFO : LogLevel.TRACE + this.hideDevLogs = process.env.HIDE_DEV_LOGS === undefined ? !this.isDev : process.env.HIDE_DEV_LOGS === '1' this.socketListeners = [] this.logManager = null @@ -92,7 +93,7 @@ class Logger { * @param {...any} args */ dev(...args) { - if (!this.isDev || process.env.HIDE_DEV_LOGS === '1') return + if (this.hideDevLogs) return console.log(`[${this.timestamp}] DEV:`, ...args) }