fix: Invalid LOG_LEVEL in environment results in server crash with no displayed error message

Related: https://github.com/outline/outline/discussions/5466
This commit is contained in:
Tom Moor
2023-06-22 09:17:25 -04:00
parent d96bf5106d
commit 831318d941

View File

@@ -30,7 +30,20 @@ class Logger {
public constructor() {
this.output = winston.createLogger({
level: env.LOG_LEVEL,
// The check for log level validity is here in addition to the ENV validation
// as entering an incorrect LOG_LEVEL in env could otherwise prevent the
// related error message from being displayed.
level: [
"error",
"warn",
"info",
"http",
"verbose",
"debug",
"silly",
].includes(env.LOG_LEVEL)
? env.LOG_LEVEL
: "info",
});
this.output.add(
new winston.transports.Console({