Skip to content

Commit 50ffa9d

Browse files
hsilievthebigredgeek
authored andcommitted
Enable use of custom log function (#379)
* Enable use of custom log function * Add test for custom log function
1 parent 1c625d4 commit 50ffa9d

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

debug.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ function createDebug(namespace) {
110110
// apply env-specific formatting (colors, etc.)
111111
exports.formatArgs.call(self, args);
112112

113-
var logFn = enabled.log || exports.log || console.log.bind(console);
113+
var logFn = debug.log || exports.log || console.log.bind(console);
114114
logFn.apply(self, args);
115115
}
116116

test/debug_spec.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { expect } from 'chai';
2+
import { assert, spy } from 'sinon';
23

34
import debug from '../index';
45

@@ -9,4 +10,22 @@ describe('debug', () => {
910
log('hello world');
1011
});
1112
});
12-
})
13+
14+
describe('custom functions', () => {
15+
let log;
16+
17+
beforeEach(() => {
18+
debug.enable('test');
19+
log = debug('test');
20+
});
21+
22+
context('with log function', () => {
23+
it('uses it', () => {
24+
log.log = spy();
25+
log('using custom log function');
26+
27+
assert.calledOnce(log.log);
28+
});
29+
});
30+
});
31+
});

0 commit comments

Comments
 (0)