UNPKG

mongodb-dynamic-api

Version:

Auto generated CRUD API for MongoDB using NestJS

44 lines 1.43 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.MongoDBDynamicApiLogger = void 0; const common_1 = require("@nestjs/common"); const process = require("node:process"); const logLevelsDictionary = { debug: ['DEBUG'], log: ['INFO', 'DEBUG'], warn: ['WARN', 'INFO', 'DEBUG'], error: ['ERROR', 'WARN', 'INFO', 'DEBUG'], }; class MongoDBDynamicApiLogger extends common_1.Logger { constructor(context) { super(context); this.isEnabled = !!process.env.MONGODB_DYNAMIC_API_LOGGER; this.logLevel = (process.env.MONGODB_DYNAMIC_API_LOGGER || 'ERROR'); } debug(...args) { if (!this.isEnabled || !logLevelsDictionary['debug'].includes(this.logLevel)) { return; } super.debug(...args); } log(...args) { if (!this.isEnabled || !logLevelsDictionary['log'].includes(this.logLevel)) { return; } super.log(...args); } warn(...args) { if (!this.isEnabled || !logLevelsDictionary['warn'].includes(this.logLevel)) { return; } super.warn(...args); } error(...args) { if (!this.isEnabled || !logLevelsDictionary['error'].includes(this.logLevel)) { return; } super.error(...args); } } exports.MongoDBDynamicApiLogger = MongoDBDynamicApiLogger; //# sourceMappingURL=mongo-dynamic-api.logger.js.map