flecks/packages/core/build/debug.js

30 lines
802 B
JavaScript

const D = require('debug');
const {
VSCODE_INSPECTOR_OPTIONS,
} = process.env;
let hasInitialized;
module.exports = (name) => {
if (!hasInitialized) {
// VSCode has a problem showing colors when formatting objects.
if (VSCODE_INSPECTOR_OPTIONS) {
const {formatArgs} = D;
D.formatArgs = function formatObjectsWithoutColor(args) {
const {useColors} = this;
if (args[0].match(/%[oO]/)) {
this.useColors = false;
}
formatArgs.call(this, args);
this.useColors = useColors;
};
D.formatters.o = undefined;
D.formatters.O = undefined;
}
const type = 'undefined' !== typeof window ? 'log' : 'error';
// eslint-disable-next-line no-console
D.log = console[type].bind(console);
}
return D(name);
};