/**
 * @returns {string}
 */
const getCurrentTime = () => {
    const date = new Date()
    return '' +
        String(date.getFullYear()) + '.' +
        String(date.getMonth()+1).padStart(2, '0') + '.' +
        String(date.getDate()).padStart(2, '0') + ' ' +
        String(date.getHours() + 5).padStart(2, '0') + ':' +
        String(date.getMinutes()).padStart(2, '0') + ':' +
        String(date.getSeconds()).padStart(2, '0')
}

/** 
 * @typedef {Object} Logger
 * @property {(msg: string) => void} print
 * @property {(wmsg: string) => void} wprint
 * @property {(emsg: string) => void} eprint
 * @property {(msg: string) => void} save
 */

/** @type {Logger} */
const logger = {
    saved: [],
    errors: [],
    warnings: [],
    logs: [],
    /** @param {string} msg */
    print: (msg) => {
        const msg_format = `${getCurrentTime()} : Log : ${msg}`
        logger.logs.push(msg_format); 
        console.log(msg_format)
    },
    /** @param {string} wmsg */
    wprint: (wmsg) => {
        const msg_format = `${getCurrentTime()} : Warning : ${wmsg}`
        logger.warnings.push(msg_format); 
        console.log(msg_format)
    },
    /** @param {string} emsg */
    eprint: (emsg) => {
        const msg_format = `${getCurrentTime()} : Error : ${emsg}`
        logger.errors.push(msg_format); 
        console.log(msg_format)
    },
    /** @param {string} msg */
    save: (msg) => logger.saved.push(`${getCurrentTime()} : Data : ${msg}`),
}