-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLogger.js
39 lines (34 loc) · 1.06 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
const Configuration = require("./Configuration");
/**
* Global logging class, all methods are static
*
* Written by Nommiin - https://github.com/Nommiin
*/
class Logger {
static _get = function(type, msg) {
return `[${Configuration.PROGRAM_NAME} - ${type}]: ${msg}`;
}
/**
* Logs an info message in the console prepended with INFO
* @param {string} msg The message to log
*/
static info(msg) {
console.log(this._get("INFO", msg));
}
/**
* Logs a warning message in the console prepended with WARNING
* @param {string} msg The message to log
*/
static warning(msg) {
console.log(this._get("WARNING", msg));
}
/**
* Logs an error message in the console prepended with ERROR
* @param {string} msg The message to log
*/
static error(msg) {
console.error(this._get("ERROR", msg));
}
}
module.exports = Logger;
if (!global["__program_main"]) if (!global["__program_warn"]) {global["__program_warn"]=1;console.error("Please execute the program by running main.js");}