Skip to content

Commit

Permalink
Move initialization to constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
neilenns committed Aug 13, 2024
1 parent b270c4e commit dd98b7e
Showing 1 changed file with 7 additions and 7 deletions.
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 @@ const TransportStream = require('winston-transport');
* @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 @@ module.exports = class Console extends TransportStream {
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 Down

0 comments on commit dd98b7e

Please sign in to comment.