Skip to content

Commit 5528572

Browse files
committedDec 19, 2018
use console.debug() in browser when available (closes #600)
also removes a branch for each logging call, slightly improving performance in the browser.
1 parent c0127b1 commit 5528572

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed
 

‎src/browser.js

+5-10
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
* This is the web browser implementation of `debug()`.
55
*/
66

7-
exports.log = log;
87
exports.formatArgs = formatArgs;
98
exports.save = save;
109
exports.load = load;
@@ -170,18 +169,14 @@ function formatArgs(args) {
170169
}
171170

172171
/**
173-
* Invokes `console.log()` when available.
174-
* No-op when `console.log` is not a "function".
172+
* Invokes `console.debug()` when available.
173+
* No-op when `console.debug` is not a "function".
174+
* If `console.debug` is not available, falls back
175+
* to `console.log`.
175176
*
176177
* @api public
177178
*/
178-
function log(...args) {
179-
// This hackery is required for IE8/9, where
180-
// the `console.log` function doesn't have 'apply'
181-
return typeof console === 'object' &&
182-
console.log &&
183-
console.log(...args);
184-
}
179+
exports.log = console.debug || console.log || (() => {});
185180

186181
/**
187182
* Save `namespaces`.

0 commit comments

Comments
 (0)
Please sign in to comment.