From 94a8011bd61eb18bf278447b0bc77a0b41b4f472 Mon Sep 17 00:00:00 2001 From: Matthew Stickney Date: Fri, 4 Aug 2023 16:45:34 -0400 Subject: [PATCH] feat: Make logfile location customizable It may be desirable to log to a more standard location (e.g. in /var/log/), or in some cases to turn logging to file off. To support these, use a custom config property to determine the location of the output log file, and default to the previous location if it is unset. --- server/.env.sample | 2 ++ server/utils/logger.js | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/server/.env.sample b/server/.env.sample index c741892..3e3dd40 100644 --- a/server/.env.sample +++ b/server/.env.sample @@ -6,6 +6,8 @@ SECRET_KEY=notsecretkey ## Optional +# LOG_FILE= + # TRUST_PROXY=0 # TOKEN_EXPIRES_IN=365 # In days diff --git a/server/utils/logger.js b/server/utils/logger.js index d1c3cc7..808222d 100644 --- a/server/utils/logger.js +++ b/server/utils/logger.js @@ -6,7 +6,8 @@ const winston = require('winston'); */ const defaultLogTimestampFormat = 'YYYY-MM-DD HH:mm:ss'; -const logfile = `${process.cwd()}/logs/planka.log`; +const logfile = + 'LOG_FILE' in process.env ? process.env.LOG_FILE : `${process.cwd()}/logs/planka.log`; /** * Log level for both console and file log sinks.