diff --git a/lib/wrap.js b/lib/wrap.js index 289c3b2..3abe3a2 100644 --- a/lib/wrap.js +++ b/lib/wrap.js @@ -19,13 +19,13 @@ var DEFAULT = require('./defaults'); module.exports = function _wrap(logger, options) { // Make base logger callable (debug) - var _CallableLogger = write(logger.debug, 'debug', options); + var _CallableLogger = write(logger, logger.debug, 'debug', options); // Mix-in log methods, but run `write` // on their arguments to improve the readability // of log output. DEFAULT.METHODS.forEach(function(logAt) { - _CallableLogger[logAt] = write(logger[logAt], logAt, options); + _CallableLogger[logAt] = write(logger, logger[logAt], logAt, options); }); return _CallableLogger; diff --git a/lib/write.js b/lib/write.js index 14dd8ed..67b7b57 100644 --- a/lib/write.js +++ b/lib/write.js @@ -21,7 +21,7 @@ var IS_NODE_8_OR_NEWER = semver.satisfies(semver.clean(process.version), '8'); * @api private */ -module.exports = function(logFn, logAt, options) { +module.exports = function(loggerObj, logFn, logAt, options) { return function _writeLogToConsole() { // Check `options.level` against logAt @@ -44,7 +44,7 @@ module.exports = function(logFn, logAt, options) { // // If `options.inspect` is disabled, just call the log fn normally if (!options.inspect) { - return logFn.apply(logFn, args); + return logFn.apply(loggerObj, args); } ///////////////////////////////////////////////////////////////// @@ -87,6 +87,6 @@ module.exports = function(logFn, logAt, options) { var str = prefixStr + util.format.apply(util, pieces); // Call log fn - return logFn.apply(logFn, [str]); + return logFn.apply(loggerObj, [str]); }; };