UNPKG

@devcycle/js-cloud-server-sdk

Version:

The DevCycle JS Cloud Bucketing Server SDK used for feature management.

32 lines 1.66 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.DVCLogLevels = void 0; exports.dvcDefaultLogger = dvcDefaultLogger; const isNumber_1 = __importDefault(require("lodash/isNumber")); const prefix = '[DevCycle]: '; var DVCLogLevels; (function (DVCLogLevels) { DVCLogLevels[DVCLogLevels["debug"] = 0] = "debug"; DVCLogLevels[DVCLogLevels["info"] = 1] = "info"; DVCLogLevels[DVCLogLevels["warn"] = 2] = "warn"; DVCLogLevels[DVCLogLevels["error"] = 3] = "error"; })(DVCLogLevels || (exports.DVCLogLevels = DVCLogLevels = {})); function dvcDefaultLogger(options) { const minLevel = (options === null || options === void 0 ? void 0 : options.level) && (0, isNumber_1.default)(DVCLogLevels[options === null || options === void 0 ? void 0 : options.level]) ? DVCLogLevels[options === null || options === void 0 ? void 0 : options.level] : DVCLogLevels.error; const logWriter = (options === null || options === void 0 ? void 0 : options.logWriter) || console.log; const writeLog = (message) => logWriter(prefix + message); // eslint-disable-next-line @typescript-eslint/no-empty-function const noOpLog = (message) => { }; return { error: DVCLogLevels.error >= minLevel ? writeLog : noOpLog, warn: DVCLogLevels.warn >= minLevel ? writeLog : noOpLog, info: DVCLogLevels.info >= minLevel ? writeLog : noOpLog, debug: DVCLogLevels.debug >= minLevel ? writeLog : noOpLog, }; } //# sourceMappingURL=logger.js.map