From 80d343939facdab4eb4aa315cb061c75a3f77549 Mon Sep 17 00:00:00 2001 From: Adrian Hope-Bailie Date: Tue, 26 Feb 2019 08:14:53 +0200 Subject: [PATCH] Expose `child` on default logger (#1603) * Add `child` pass-through to type defs * Add pass-through to defaultLogger.child(...) * Add test for `winston.child` * fix: type defs --- index.d.ts | 1 + lib/winston.js | 3 ++- test/winston.test.js | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/index.d.ts b/index.d.ts index 36b64aa7b..236ce5595 100644 --- a/index.d.ts +++ b/index.d.ts @@ -169,6 +169,7 @@ declare namespace winston { let startTimer: () => Profiler; let profile: (id: string | number) => Logger; let configure: (options: LoggerOptions) => void; + let child: (options: Object) => Logger; let level: string; let exceptions: ExceptionHandler; let exitOnError: Function | boolean; diff --git a/lib/winston.js b/lib/winston.js index 7e4e29ae8..e0c4e3cac 100644 --- a/lib/winston.js +++ b/lib/winston.js @@ -104,7 +104,8 @@ Object.keys(winston.config.npm.levels) 'unhandleExceptions', 'handleRejections', 'unhandleRejections', - 'configure' + 'configure', + 'child' ]) .forEach( method => (winston[method] = (...args) => defaultLogger[method](...args)) diff --git a/test/winston.test.js b/test/winston.test.js index 30fd64ead..a24c39113 100644 --- a/test/winston.test.js +++ b/test/winston.test.js @@ -27,7 +27,7 @@ describe('winston', function () { it('has expected methods', function () { assume(winston.config).is.an('object'); - ['createLogger', 'add', 'remove', 'clear'] + ['createLogger', 'add', 'remove', 'clear', 'child'] .concat(Object.keys(winston.config.npm.levels)) .forEach(function (key) { assume(winston[key]).is.a('function', 'winston.' + key);