const {createLogger, format, transports} = require('winston');
const {_, formatDate} = require('../workers/mongo_manager')
const path = require("path");
const {printf, label, timestamp, combine} = format;
const homedir = require('os').homedir();

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.Console(),
        new transports.File({filename: path.join(homedir, "appointment_" + formatDate(new Date()) + ".log")}),
    ],
});

module.exports = appointmentLogger