UNPKG

dbgate-tools

Version:

Auxiliary tools for other DbGate packages.

45 lines (44 loc) 1.39 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; var _a; Object.defineProperty(exports, "__esModule", { value: true }); exports.getLogger = exports.setLoggerName = exports.setLogConfig = void 0; const pinomin_1 = __importDefault(require("pinomin")); let _logConfig; let _name = null; const defaultLogConfig = { base: { pid: (_a = global === null || global === void 0 ? void 0 : global.process) === null || _a === void 0 ? void 0 : _a.pid }, targets: [{ type: 'console', level: 'info' }], }; function setLogConfig(value) { _logConfig = value; } exports.setLogConfig = setLogConfig; function setLoggerName(value) { _name = value; } exports.setLoggerName = setLoggerName; function getLogger(caller) { return (0, pinomin_1.default)({ getConfig: () => { const config = _logConfig || defaultLogConfig; if (caller) { const props = { caller }; if (_name) { props['name'] = _name; } return { ...config, base: { ...config.base, ...props, }, }; } return config; }, }); } exports.getLogger = getLogger;