-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
log.js
46 lines (38 loc) · 1.13 KB
/
log.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
var config = require("./config.js"),
pjson = require("./package.json");
const chalk = require("chalk");
function trace(template, ...args) {
if (config.flag("debug")) {
console.log(chalk.white("[TRACE] ") + template, ...args);
}
}
function debug(template, ...args) {
if (config.flag("debug")) {
console.log(chalk.white("[DEBUG] ") + template, ...args);
}
}
function info(template, ...args) {
console.log(chalk.cyan("[INFO] ")+template, ...args);
}
function warn(template, ...args) {
console.log(chalk.yellow("[WARN] ")+template, ...args);
}
function error(template, ...args) {
console.log(chalk.redBright("[ERROR] ")+template, ...args);
if (config.flag("debug")) {
djserver.report_error(util.format(template, ...args));
}
}
function fatal(template, ...args) {
console.log(chalk.redBright("[ERROR] ")+template, ...args);
if (config.flag("debug")) {
djserver.report_error(util.format(template, ...args));
}
process.exit(255);
}
exports.trace = trace;
exports.debug = debug;
exports.info = info;
exports.warn = warn;
exports.error = error;
exports.fatal = fatal;