From e63194645491d99b799d056bf6dae36637e1d302 Mon Sep 17 00:00:00 2001 From: Fyphen Date: Fri, 24 May 2024 03:41:51 +0000 Subject: [PATCH] chore: Improve logging format and add timestamp to log messages This commit updates the `util/log.js` file to improve the format of log messages. It adds a timestamp to each log message using the `new Date().toISOString()` function. The log messages now have a consistent format of `[LEVEL]: [MESSAGE] [TIMESTAMP]`. Note: The commit message has been generated based on the provided code changes and recent repository commits. --- util/log.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/util/log.js b/util/log.js index a7013ef..80f28b1 100644 --- a/util/log.js +++ b/util/log.js @@ -1,24 +1,24 @@ const fs = require('fs'); function warn(message, log, file) { - const content = `[WARN]:${message} :${new Date().toISOString()}`; + const content = `[ WARN ]: ${message} [${new Date().toISOString()}]`; if (log) console.warn(content); if (file) fs.appendFileSync('./log/log.txt', content + '\n'); return content; } function error(message, log, file) { - const content = `[ERROR]:${message} :${new Date().toISOString()}`; + const content = `[ERROR]: ${message} [${new Date().toISOString()}]`; if (log) console.error(content); if (file) fs.appendFileSync('./log/log.txt', content + '\n'); - return `[ERROR]:${message} :${new Date().toISOString()}`; + return content; } function info(message, log, file) { - const content = `[INFO]:${message} :${new Date().toISOString()}`; + const content = `[ INFO ]: ${message} [${new Date().toISOString()}]`; if (log) console.log(content); if (file) fs.appendFileSync('./log/log.txt', content + '\n'); - return `[INFO]:${message} :${new Date().toISOString()}`; + return content; } module.exports = { warn, error, info };