Skip to content

Commit

Permalink
Expose child on default logger (#1603)
Browse files Browse the repository at this point in the history
* Add `child` pass-through to type defs

* Add pass-through to defaultLogger.child(...)

* Add test for `winston.child`

* fix: type defs
  • Loading branch information
adrianhopebailie authored and DABH committed Feb 26, 2019
1 parent 3a5413b commit 80d3439
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion lib/winston.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ Object.keys(winston.config.npm.levels)
'unhandleExceptions',
'handleRejections',
'unhandleRejections',
'configure'
'configure',
'child'
])
.forEach(
method => (winston[method] = (...args) => defaultLogger[method](...args))
Expand Down
2 changes: 1 addition & 1 deletion test/winston.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 80d3439

Please sign in to comment.