mirror of
https://github.com/debug-js/debug.git
synced 2025-12-08 20:59:48 +00:00
copy custom logger to namespace extension (fixes #646)
This commit is contained in:
parent
5528572f9a
commit
825d35a2da
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
8
test.js
8
test.js
@ -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)', () => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user