UNPKG

newmax-utils

Version:
30 lines (29 loc) 951 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.logger = void 0; const pino_1 = require("pino"); const path_1 = require("path"); const Moment_1 = require("./Moment"); const env_1 = require("../configs/env"); const file = (0, path_1.join)('./logs', `${Moment_1.Moment.formatCurrentDate()}.log`); const targets = [ { target: 'pino-pretty', options: { colorize: true, ignore: 'hostname,pid', translateTime: 'yy-mm-dd HH:MM:ss' }, level: 'info', }, { target: 'pino/file', options: { destination: file, mkdir: true, sync: true }, }, ]; if (env_1.env.BETTERSTACK_TOKEN) { targets.push({ target: '@logtail/pino', options: { sourceToken: env_1.env.BETTERSTACK_TOKEN }, level: 'info', }); } const config = { targets }; const transports = pino_1.pino.transport(config); exports.logger = (0, pino_1.pino)({ level: 'info' }, transports);