Skip to content

Commit 57ef085

Browse files
committedDec 22, 2018
copy custom logger to namespace extension (fixes #646)
1 parent d0e498f commit 57ef085

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed
 

‎src/common.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,9 @@ function setup(env) {
143143
}
144144

145145
function extend(namespace, delimiter) {
146-
return createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
146+
const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
147+
newDebug.log = this.log;
148+
return newDebug;
147149
}
148150

149151
/**

‎test.js

+8
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,14 @@ describe('debug', () => {
8080
const logBar = log.extend('bar', '');
8181
expect(logBar.namespace).to.be.equal('foobar');
8282
});
83+
84+
it('should keep the log function between extensions', () => {
85+
const log = debug('foo');
86+
log.log = () => {};
87+
88+
const logBar = log.extend('bar');
89+
expect(log.log).to.be.equal(logBar.log);
90+
});
8391
});
8492

8593
describe('rebuild namespaces string (disable)', () => {

0 commit comments

Comments
 (0)
Please sign in to comment.