Skip to content

Commit 825d35a

Browse files
committedDec 19, 2018
copy custom logger to namespace extension (fixes #646)
1 parent 5528572 commit 825d35a

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
@@ -70,6 +70,14 @@ describe('debug', () => {
7070
const logBar = log.extend('bar', '');
7171
assert.deepStrictEqual(logBar.namespace, 'foobar');
7272
});
73+
74+
it('should keep the log function between extensions', () => {
75+
const log = debug('foo');
76+
log.log = () => {};
77+
78+
const logBar = log.extend('bar');
79+
assert.deepStrictEqual(log.log, logBar.log);
80+
});
7381
});
7482

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

0 commit comments

Comments
 (0)
Please sign in to comment.