diff --git a/README.md b/README.md index 88dae35d..9fabfd50 100644 --- a/README.md +++ b/README.md @@ -168,6 +168,7 @@ change the behavior of the debug logging: | `DEBUG` | Enables/disables specific debugging namespaces. | | `DEBUG_HIDE_DATE` | Hide date from debug output (non-TTY). | | `DEBUG_COLORS`| Whether or not to use colors in the debug output. | +| `DEBUG_COLORS_NODE` | Assume runtime is Node, even if it looks like a browser (e.g. Electron). | | `DEBUG_DEPTH` | Object inspection depth. | | `DEBUG_SHOW_HIDDEN` | Shows hidden properties on inspected objects. | diff --git a/src/browser.js b/src/browser.js index ac3f7e13..a13a9d7c 100644 --- a/src/browser.js +++ b/src/browser.js @@ -169,14 +169,11 @@ function formatArgs(args) { } /** - * 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`. + * Invokes `console.log` if available or no-op * * @api public */ -exports.log = console.debug || console.log || (() => {}); +exports.log = console.log || (() => {}); /** * Save `namespaces`. diff --git a/src/index.js b/src/index.js index bf4c57f2..cdc34d8a 100644 --- a/src/index.js +++ b/src/index.js @@ -3,7 +3,10 @@ * treat as a browser. */ -if (typeof process === 'undefined' || process.type === 'renderer' || process.browser === true || process.__nwjs) { +const isBrowserNode = process.type === 'renderer' || process.browser === true || process.__nwjs; +const isBrowser = typeof process === 'undefined'; + +if (isBrowser || (isBrowserNode && !process.env.DEBUG_COLORS_NODE)) { module.exports = require('./browser.js'); } else { module.exports = require('./node.js'); diff --git a/src/node.js b/src/node.js index 5e1f1541..c2fa8610 100644 --- a/src/node.js +++ b/src/node.js @@ -128,6 +128,11 @@ exports.inspectOpts = Object.keys(process.env).filter(key => { return k.toUpperCase(); }); + if (prop === 'colorsNode') { + obj.colors = true; + return obj; + } + // Coerce string value into JS value let val = process.env[key]; if (/^(yes|on|true|enabled)$/i.test(val)) {