Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1491 custom log levels can be silent #2366

Closed
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
set undefined log levels to be silent
ckujawa committed Aug 25, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 6e0444c1d7123be09547a8211c20b39cef5aec48
11 changes: 11 additions & 0 deletions lib/winston/logger.js
Original file line number Diff line number Diff line change
@@ -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);
}