copy custom logger to namespace extension (fixes #646)

This commit is contained in:
Josh Junon 2018-12-19 04:56:06 +01:00 committed by Qix
parent 5528572f9a
commit 825d35a2da
2 changed files with 11 additions and 1 deletions

View File

@ -143,7 +143,9 @@ function setup(env) {
}
function extend(namespace, delimiter) {
return createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
newDebug.log = this.log;
return newDebug;
}
/**

View File

@ -70,6 +70,14 @@ describe('debug', () => {
const logBar = log.extend('bar', '');
assert.deepStrictEqual(logBar.namespace, 'foobar');
});
it('should keep the log function between extensions', () => {
const log = debug('foo');
log.log = () => {};
const logBar = log.extend('bar');
assert.deepStrictEqual(log.log, logBar.log);
});
});
describe('rebuild namespaces string (disable)', () => {