diff --git a/lib/winston/transports/console.js b/lib/winston/transports/console.js index 0679045eb..25ab78469 100644 --- a/lib/winston/transports/console.js +++ b/lib/winston/transports/console.js @@ -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. @@ -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); }