log to file

This commit is contained in:
2022-09-15 22:21:03 +02:00
parent 2a8d6afc88
commit 7eafc24e23
6 changed files with 61 additions and 31 deletions
+21
View File
@@ -0,0 +1,21 @@
const {createLogger, format, transports} = require('winston');
const {_, formatDate} = require('../workers/mongo_manager')
const {printf, label, timestamp, combine} = format;
const myFormat = printf(({level, message, label, timestamp}) => {
return `${timestamp} [${label}] ${level}: ${message}`;
});
const appointmentLogger = createLogger({
level: 'info',
format: combine(
label({label: 'appointment'}),
timestamp(),
myFormat
),
transports: [
new transports.File({filename: "appointment_" + formatDate(new Date()) + ".log"}),
],
});
module.exports = appointmentLogger