"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const chalk_1 = tslib_1.__importDefault(require("chalk"));
const winston_1 = tslib_1.__importStar(require("winston"));
const logLevels = {
    error: 0,
    warning: 1,
    success: 2,
    info: 3,
};
const consoleFormat = winston_1.format.printf((info) => {
    const { level, message } = info;
    switch (level) {
        case 'error':
            return `${chalk_1.default.red(level)} ${message}`;
        case 'warning':
            return `${chalk_1.default.yellow(level)} ${message}`;
        case 'success':
            return `${chalk_1.default.green(level)} ${message}`;
        case 'info':
            return `${chalk_1.default.blue(level)} ${message}`;
        default:
            return message;
    }
});
const fileFormat = winston_1.format.printf((info) => {
    const { message, error, timestamp } = info;
    let log = `${timestamp} ${message}\n`;
    if (error) {
        const { message, stack } = error;
        log += `${message}\n${stack}\n`;
    }
    return log;
});
const logger = winston_1.default.createLogger({
    levels: logLevels,
    transports: [
        new winston_1.default.transports.Console({ level: 'info', format: consoleFormat }),
    ],
});
exports.default = logger;
