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

Move initialization to constructor #2503

Merged
merged 1 commit into from
Aug 14, 2024
Merged
Changes from all commits
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
14 changes: 7 additions & 7 deletions lib/winston/transports/console.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,6 @@
* @extends {TransportStream}
*/
module.exports = class Console extends TransportStream {
// Keep a reference to the log, warn, and error console methods
// in case they get redirected to this transport after the logger is
// instantiated. This prevents a circular reference issue.
_consoleLog = console.log.bind(console);
_consoleWarn = console.warn.bind(console);
_consoleError = console.error.bind(console);

/**
* Constructor function for the Console transport object responsible for
* persisting log messages and metadata to a terminal or TTY.
Expand All @@ -40,6 +33,13 @@
this.eol = typeof options.eol === 'string' ? options.eol : os.EOL;
this.forceConsole = options.forceConsole || false;

// Keep a reference to the log, warn, and error console methods
// in case they get redirected to this transport after the logger is
// instantiated. This prevents a circular reference issue.
this._consoleLog = console.log.bind(console);
this._consoleWarn = console.warn.bind(console);
this._consoleError = console.error.bind(console);

this.setMaxListeners(30);
}

Expand All @@ -49,7 +49,7 @@
* @param {Function} callback - TODO: add param description.
* @returns {undefined}
*/
log(info, callback) {

Check warning on line 52 in lib/winston/transports/console.js

View workflow job for this annotation

GitHub Actions / Tests (16)

Method 'log' has too many statements (19). Maximum allowed is 15

Check warning on line 52 in lib/winston/transports/console.js

View workflow job for this annotation

GitHub Actions / Tests (16)

Method 'log' has a complexity of 12. Maximum allowed is 11

Check warning on line 52 in lib/winston/transports/console.js

View workflow job for this annotation

GitHub Actions / Tests (18)

Method 'log' has too many statements (19). Maximum allowed is 15

Check warning on line 52 in lib/winston/transports/console.js

View workflow job for this annotation

GitHub Actions / Tests (18)

Method 'log' has a complexity of 12. Maximum allowed is 11

Check warning on line 52 in lib/winston/transports/console.js

View workflow job for this annotation

GitHub Actions / Tests (20)

Method 'log' has too many statements (19). Maximum allowed is 15

Check warning on line 52 in lib/winston/transports/console.js

View workflow job for this annotation

GitHub Actions / Tests (20)

Method 'log' has a complexity of 12. Maximum allowed is 11
setImmediate(() => this.emit('logged', info));

// Remark: what if there is no raw...?
Expand Down
Loading