Skip to content

Commit

Permalink
set undefined log levels to be silent
Browse files Browse the repository at this point in the history
  • Loading branch information
ckujawa committed Aug 25, 2023
1 parent 914b846 commit 6e0444c
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/winston/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,17 @@ class Logger extends Transform {
);
}

if (!Object.keys(this.levels).includes(this.level)){
const message = [
'[winston] Log level <${this.level}> is not defined in levels definition.',
'Please double check the setup of your transports and/or custom log levels.',
'This transport will be set to silent.',
'See https://github.com/winstonjs/winston#logging-levels for more information.'
]
console.warn(message.join('\n'));
this.silent = true;
}

if (exceptionHandlers) {
this.exceptions.handle(exceptionHandlers);
}
Expand Down

0 comments on commit 6e0444c

Please sign in to comment.