flecks/packages/core/build/debug.js

30 lines
821 B
JavaScript
Raw Normal View History

2022-03-01 10:14:38 -06:00
const D = require('debug');
2022-02-28 10:29:56 -06:00
const {
VSCODE_INSPECTOR_OPTIONS,
} = process.env;
let hasInitialized;
2022-03-01 10:14:38 -06:00
module.exports = (name) => {
2022-02-28 10:29:56 -06:00
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;
}
2024-01-22 09:16:07 -06:00
const type = 'web' === process.env.FLECKS_CORE_BUILD_TARGET ? 'debug' : 'error';
2022-02-28 10:29:56 -06:00
// eslint-disable-next-line no-console
2022-04-04 04:42:01 -05:00
D.log = console[type].bind(console);
2022-02-28 10:29:56 -06:00
}
return D(name);
};