better-logging
Version:
better-logging is a drop in replacement for the default logging methods of node.js
26 lines (25 loc) • 799 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConfigCache = void 0;
const configs = new WeakMap();
const setConfig = (key, config) => {
if (typeof key === 'function') {
configs.set(key, config);
return;
}
const { debug, error, info, line, log, warn } = key;
setConfig(debug, config);
setConfig(error, config);
setConfig(info, config);
setConfig(line, config);
setConfig(log, config);
setConfig(warn, config);
};
const getConfig = (key) => {
var _a, _b;
if (typeof key === 'function') {
return (_a = configs.get(key)) !== null && _a !== void 0 ? _a : null;
}
return (_b = configs.get(key.info)) !== null && _b !== void 0 ? _b : null;
};
exports.ConfigCache = { setConfig, getConfig };
;