Skip to content

Commit e631946

Browse files
committed
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.
1 parent a5e8800 commit e631946

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

util/log.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
const fs = require('fs');
22

33
function warn(message, log, file) {
4-
const content = `[WARN]:${message} :${new Date().toISOString()}`;
4+
const content = `[ WARN ]: ${message} [${new Date().toISOString()}]`;
55
if (log) console.warn(content);
66
if (file) fs.appendFileSync('./log/log.txt', content + '\n');
77
return content;
88
}
99

1010
function error(message, log, file) {
11-
const content = `[ERROR]:${message} :${new Date().toISOString()}`;
11+
const content = `[ERROR]: ${message} [${new Date().toISOString()}]`;
1212
if (log) console.error(content);
1313
if (file) fs.appendFileSync('./log/log.txt', content + '\n');
14-
return `[ERROR]:${message} :${new Date().toISOString()}`;
14+
return content;
1515
}
1616

1717
function info(message, log, file) {
18-
const content = `[INFO]:${message} :${new Date().toISOString()}`;
18+
const content = `[ INFO ]: ${message} [${new Date().toISOString()}]`;
1919
if (log) console.log(content);
2020
if (file) fs.appendFileSync('./log/log.txt', content + '\n');
21-
return `[INFO]:${message} :${new Date().toISOString()}`;
21+
return content;
2222
}
2323

2424
module.exports = { warn, error, info };

0 commit comments

Comments
 (0)