common-core-pkg
Version:
Common package for all the utils
62 lines • 2.49 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.createWinstonLoggerOptions = exports.winstonLoggerOptions = void 0;
const winston = require("winston");
const nest_winston_1 = require("nest-winston");
require("winston-daily-rotate-file");
const dailyRotateTransport = new winston.transports.DailyRotateFile({
dirname: 'logs',
filename: 'application-%DATE%.log',
datePattern: 'YYYY-MM-DD',
zippedArchive: true,
maxSize: '20m',
maxFiles: '14d',
level: 'info',
});
const errorRotateTransport = new winston.transports.DailyRotateFile({
dirname: 'logs',
filename: 'error-%DATE%.log',
datePattern: 'YYYY-MM-DD',
zippedArchive: true,
maxSize: '10m',
maxFiles: '30d',
level: 'error',
});
exports.winstonLoggerOptions = {
level: 'debug',
format: winston.format.combine(winston.format.timestamp(), winston.format.errors({ stack: true }), winston.format.json()),
transports: [
new winston.transports.Console({
format: winston.format.combine(winston.format.colorize({ all: true }), winston.format.timestamp(), nest_winston_1.utilities.format.nestLike('App', {
prettyPrint: true,
}), winston.format.printf(({ timestamp, level, message }) => {
return `[USER-MANAGEMENT-APP] ${process.pid} ${timestamp} ${level} ${message}`;
})),
}),
dailyRotateTransport,
errorRotateTransport,
new winston.transports.File({
filename: 'logs/app.log',
level: 'info',
}),
],
};
const createWinstonLoggerOptions = (appName) => ({
level: 'debug',
format: winston.format.combine(winston.format.timestamp(), winston.format.errors({ stack: true }), winston.format.json()),
transports: [
new winston.transports.Console({
format: winston.format.combine(winston.format.colorize({ all: true }), winston.format.timestamp(), nest_winston_1.utilities.format.nestLike(appName, { prettyPrint: true }), winston.format.printf(({ timestamp, level, message }) => {
return `[${appName}] ${process.pid} ${timestamp} ${level} ${message}`;
})),
}),
dailyRotateTransport,
errorRotateTransport,
new winston.transports.File({
filename: 'logs/app.log',
level: 'info',
}),
],
});
exports.createWinstonLoggerOptions = createWinstonLoggerOptions;
//# sourceMappingURL=index.js.map