-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLogger.js
More file actions
42 lines (34 loc) · 1.41 KB
/
Logger.js
File metadata and controls
42 lines (34 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
Logger class for easy and aesthetically pleasing console logging
Logger is from AnIdiotsGuide guidebot
*/
const chalk = require("chalk");
const moment = require("moment");
exports.log = (content, type = "log") => {
const timestamp = `[${moment().format("YYYY-MM-DD HH:mm:ss")}]:`;
switch (type) {
case "log": {
return console.log(`${timestamp} ${chalk.bgBlue(type.toUpperCase())} ${content} `);
}
case "warn": {
return console.log(`${timestamp} ${chalk.black.bgYellow(type.toUpperCase())} ${content} `);
}
case "error": {
return console.log(`${timestamp} ${chalk.bgRed(type.toUpperCase())} ${content} `);
}
case "debug": {
return console.log(`${timestamp} ${chalk.green(type.toUpperCase())} ${content} `);
}
case "cmd": {
return console.log(`${timestamp} ${chalk.black.bgWhite(type.toUpperCase())} ${content}`);
}
case "ready": {
return console.log(`${timestamp} ${chalk.black.bgGreen(type.toUpperCase())} ${content}`);
}
default: throw new TypeError("Logger type must be either warn, debug, log, ready, cmd or error.");
}
};
exports.error = (...args) => this.log(...args, "error");
exports.warn = (...args) => this.log(...args, "warn");
exports.debug = (...args) => this.log(...args, "debug");
exports.cmd = (...args) => this.log(...args, "cmd");