From e1595b816ea794019c913db41cfd3135bb0c03ca Mon Sep 17 00:00:00 2001 From: Josh Junon Date: Wed, 19 Dec 2018 04:41:05 +0100 Subject: [PATCH] use console.debug() in browser when available (closes #600) also removes a branch for each logging call, slightly improving performance in the browser. --- src/browser.js | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/browser.js b/src/browser.js index 5f34c0d0..0784bc3b 100644 --- a/src/browser.js +++ b/src/browser.js @@ -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`.