UNPKG

dino-core

Version:

A dependency injection framework for NodeJS applications

61 lines 2.23 kB
"use strict"; // Copyright 2018 Quirino Brizi [quirino.brizi@gmail.com] // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. Object.defineProperty(exports, "__esModule", { value: true }); exports.Logger = void 0; const tslib_1 = require("tslib"); const winston_1 = tslib_1.__importDefault(require("winston")); const errorStackFormat = winston_1.default.format((info) => { if (info instanceof Error) { return Object.assign({}, info, { stack: info.stack, message: info.message }); } return info; }); // eslint-disable-next-line @typescript-eslint/no-extraneous-class class Logger { static isLevelEnabled(level) { return Logger.concreteLogger.isLevelEnabled(level); } static error(message, ...meta) { Logger.concreteLogger.error(message, meta); return this; } static warn(message, ...meta) { Logger.concreteLogger.warn(message, meta); return this; } static info(message, ...meta) { Logger.concreteLogger.info(message, meta); return this; } static debug(message, ...meta) { Logger.concreteLogger.debug(message, meta); return this; } static silly(message, ...meta) { Logger.concreteLogger.silly(message, meta); return this; } } exports.Logger = Logger; Logger.concreteLogger = winston_1.default.createLogger({ level: process.env.LOG_LEVEL ?? 'info', transports: [new winston_1.default.transports.Console()], exitOnError: false, format: winston_1.default.format.combine(errorStackFormat(), winston_1.default.format.timestamp(), winston_1.default.format.json()) }); //# sourceMappingURL=Logger.js.map