This repository has been archived by the owner on Feb 21, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogger.js
53 lines (40 loc) · 1.78 KB
/
logger.js
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
43
44
45
46
47
48
49
50
51
52
53
const colors = require("colors");
let logDate = () => {
const date = new Date();
let hourD = date.getHours(),
minD = date.getMinutes(),
secD = date.getSeconds();
let h = (hourD < 10 ? "0" : "") + hourD,
m = (minD < 10 ? "0" : "") + minD,
s = (secD < 10 ? "0": "") + secD;
return `[${h}:${m}:${s}]`;
};
let checkString = (input) => {
if (input === true || input === false || input === 0) {
return input.toString();
} else if (!input || input === 1) {
return "true";
}
};
module.exports = {
error: function(content, bool) {
let string = checkString(bool);
let logText = string === "true" ? `${colors.bgRed(`[ERROR!]`)} ${colors.red(`${logDate()}:`)} ${content}` : `${colors.bgRed(`[ERROR!]`)}${colors.red(`:`)} ${content}`;
console.log(logText);
},
info: function(content, bool) {
let string = checkString(bool);
let logText = string === "true" ? `${colors.bgCyan(`[INFO]`)} ${colors.cyan(`${logDate()}:`)} ${content}` : `${colors.bgCyan(`[INFO]`)}${colors.cyan(`:`)} ${content}`;
console.log(logText);
},
warn: function(content, bool) {
let string = checkString(bool);
let logText = string === "true" ? `${colors.bgYellow.black(`[WARN!]`)} ${colors.yellow(`${logDate()}:`)} ${content}` : `${colors.bgYellow.black(`[WARN!]`)}${colors.yellow(`:`)} ${content}`;
console.log(logText);
},
completed: function(content, bool) {
let string = checkString(bool);
let logText = string === "true" ? `${colors.bgGreen.black(`[COMPLETED]`)} ${colors.green(`${logDate()}:`)} ${content}` : `${colors.bgGreen.black(`[COMPLETED]`)}${colors.green(`:`)} ${content}`;
console.log(logText);
}
};