Skip to content

Commit

Permalink
use console.debug() in browser when available (closes #600)
Browse files Browse the repository at this point in the history
also removes a branch for each logging call, slightly improving
performance in the browser.
  • Loading branch information
Qix- committed Dec 19, 2018
1 parent 0e94034 commit a82bd41
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/browser.js
Expand Up @@ -170,18 +170,14 @@ function formatArgs(args) {
}

/**
* Invokes `console.log()` when available.
* No-op when `console.log` is not a "function".
* Invokes `console.debug()` when available.
* No-op when `console.debug` is not a "function".
* If `console.debug` is not available, falls back
* to `console.log`.
*
* @api public
*/
function log(...args) {
// This hackery is required for IE8/9, where
// the `console.log` function doesn't have 'apply'
return typeof console === 'object' &&
console.log &&
console.log(...args);
}
const log = console.debug || console.log || () => {};

/**
* Save `namespaces`.
Expand Down

0 comments on commit a82bd41

Please sign in to comment.