From 64a05111bfe9b077b1af68e1aad67455a97c5456 Mon Sep 17 00:00:00 2001 From: Eugene <65178775+dev-whoan@users.noreply.github.com> Date: Mon, 26 Feb 2024 14:41:44 +0900 Subject: [PATCH] Prettier --- logger/index.js | 146 ++++++++++++++++++++++++------------------------ 1 file changed, 73 insertions(+), 73 deletions(-) diff --git a/logger/index.js b/logger/index.js index b837498..1164271 100644 --- a/logger/index.js +++ b/logger/index.js @@ -5,7 +5,7 @@ import ConfigReader from '../configReader/configReader.js'; import API_TYPE from '../enum/apiType.js'; export default class Logger { - + constructor(level, caller){ this.logSetting = ConfigReader.instance.getConfig()[API_TYPE.LOGGER]; this.logFile = path.join(process.env.PWD, 'logs', 'mapi.log'); @@ -39,108 +39,108 @@ export default class Logger { try { let prefix = this.TAG; prefix += `[${this.caller}]` - if(this.logSetting['time-log'] === 'yes') - { + if(this.logSetting['time-log'] === 'yes') + { prefix += `(${new Date().toLocaleString()})`; - } + } prefix += ': ' const outstream = `${prefix} ${msg}` fs.appendFileSync(this.logFile, `${outstream}\r\n`, 'utf-8'); console.log(outstream); - }catch (e){ + }catch (e){ console.error(e.stack || e); console.error("Unknown error occured while logging msg::\n", msg); - } + } } debug(msg){ if(this.logSetting.level) { - switch(this.logSetting.level) { - case "error": case "warn": case "info": - return; - } - } - - switch(this.level) - { - case "debug": - this.log(`[-DEBUG-] ${msg}`); - break; - } + switch(this.logSetting.level) { + case "error": case "warn": case "info": + return; + } + } + + switch(this.level) + { + case "debug": + this.log(`[-DEBUG-] ${msg}`); + break; + } } info(msg){ if(this.logSetting.level) { - switch(this.logSetting.level) { - case "error": case "warn": - return; - } - } - - switch(this.level) - { - case "info": case "debug": - this.log(msg); - break; - } + switch(this.logSetting.level) { + case "error": case "warn": + return; + } + } + + switch(this.level) + { + case "info": case "debug": + this.log(msg); + break; + } } warn(msg){ if(this.logSetting.level) { - switch(this.logSetting.level) { - case "error": - return; - } - } - - switch(this.level) - { - case "info": case "warn": case "debug": - this.log(`[*WARN*] ${msg}`); - break; - } + switch(this.logSetting.level) { + case "error": + return; + } + } + + switch(this.level) + { + case "info": case "warn": case "debug": + this.log(`[*WARN*] ${msg}`); + break; + } } error(msg){ switch(this.level) - { - case "info": case "warn": case "error": case "debug": - this.log(`[**ERROR**] ${msg}`); - break; - } + { + case "info": case "warn": case "error": case "debug": + this.log(`[**ERROR**] ${msg}`); + break; + } } temp(msg, doFlush){ if(this.tempMessage != null) { - if(doFlush) - { - warn(" --AUTO FLUSHING--: " + this.tempMessage); - this.tempMessage = null; - return; - } - - if(msg != null) - this.tempMessage += "\n" + msg; - }else { - if(msg != null) - this.tempMessage = msg; - } + if(doFlush) + { + warn(" --AUTO FLUSHING--: " + this.tempMessage); + this.tempMessage = null; + return; + } + + if(msg != null) + this.tempMessage += "\n" + msg; + }else { + if(msg != null) + this.tempMessage = msg; + } } flush(msgType){ if(this.tempMessage != null) - { - if(msgType == "info") - this.info(this.tempMessage); - else if(msgType == "warn") - this.warn(this.tempMessage); - else if(msgType == "error") - this.error(this.tempMessage); - else if(msgType == "debug") - this.debug(this.tempMessage); - - this.tempMessage = null; - } + { + if(msgType == "info") + this.info(this.tempMessage); + else if(msgType == "warn") + this.warn(this.tempMessage); + else if(msgType == "error") + this.error(this.tempMessage); + else if(msgType == "debug") + this.debug(this.tempMessage); + + this.tempMessage = null; + } } -} \ No newline at end of file +}