"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.removeProgressBar = exports.setProgressBar = exports.debug = exports.verbose = exports.info = exports.warn = exports.error = void 0;
const winston_1 = __importDefault(require("winston"));
let progressBar = null;
const setProgressBar = (bar) => {
    progressBar = bar;
};
exports.setProgressBar = setProgressBar;
const removeProgressBar = () => {
    progressBar = null;
};
exports.removeProgressBar = removeProgressBar;
const consoleTransport = new winston_1.default.transports.Console({
    colorize: true,
    handleExceptions: true,
    humanReadableUnhandledException: true,
    level: 'debug',
    showLevel: true,
});
winston_1.default.configure({
    exitOnError: false,
    transports: [consoleTransport],
});
// create a wrapper for error messages
const errorWrap = (input) => {
    if (progressBar) {
        progressBar.interruptBegin();
        winston_1.default.error(input);
        progressBar.interruptEnd();
    }
    else {
        winston_1.default.error(input);
    }
};
exports.error = errorWrap;
// create a wrapper for warning messages
const warnWrap = (input) => {
    if (progressBar) {
        progressBar.interruptBegin();
        winston_1.default.warn(input);
        progressBar.interruptEnd();
    }
    else {
        winston_1.default.warn(input);
    }
};
exports.warn = warnWrap;
// create a wrapper for info messages
const infoWrap = (input) => {
    if (progressBar) {
        progressBar.interruptBegin();
        winston_1.default.info(input);
        progressBar.interruptEnd();
    }
    else {
        winston_1.default.info(input);
    }
};
exports.info = infoWrap;
const { debug } = winston_1.default;
exports.debug = debug;
const { verbose } = winston_1.default;
exports.verbose = verbose;
//# sourceMappingURL=logger.js.map