12345678910111213141516171819202122232425262728293031323334353637383940 |
- "use strict";
- var __importDefault = (this && this.__importDefault) || function (mod) {
- return (mod && mod.__esModule) ? mod : { "default": mod };
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.Logger = void 0;
- const pino_1 = __importDefault(require("pino"));
- const pino_http_1 = __importDefault(require("pino-http"));
- const MessageTypes_1 = require("./MessageTypes");
- const http_1 = require("../http");
- class Logger {
- constructor() {
- this.logger = (0, pino_1.default)({
- transport: {
- target: 'pino-pretty',
- options: {
- translateTime: 'yyyy-mm-dd HH:MM:ss.l o',
- }
- }
- });
- this.httpLogger = (0, pino_http_1.default)({
- logger: this.logger,
- customLogLevel: (req, res, err) => {
- if (res.statusCode >= http_1.StatusCodes.INTERNAL_SERVER_ERROR || err)
- return MessageTypes_1.MessageTypes.ERROR;
- if (res.statusCode >= http_1.StatusCodes.BAD_REQUEST)
- return MessageTypes_1.MessageTypes.WARNING;
- return MessageTypes_1.MessageTypes.INFO;
- },
- });
- }
- getLogger() {
- return this.logger;
- }
- getHttpLogger() {
- return this.httpLogger;
- }
- }
- exports.Logger = Logger;
- //# sourceMappingURL=Logger.js.map
|