-
Notifications
You must be signed in to change notification settings - Fork 1
/
logging.js
36 lines (32 loc) · 1.06 KB
/
logging.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
const logTypes = [
"Debug",
"Info",
"Warning",
"Error"
];
const dateFormat = {hour12:false,hour:'numeric', minute:'numeric',second:'numeric'};
class Logger {
static log(iType, sText) {
if(iType == 0 && !MAIN.Config.application.debug)
{
return;
}
console.log(`${new Date().toLocaleString('UTC', dateFormat)} | [${logTypes[iType]}] ${sText}`);
}
static error(sText) {
console.error(`${new Date().toLocaleString('UTC', dateFormat)} | [${logTypes[3]}] ${sText}`)
}
static noteError(sContext) {
return function(e)
{
Logger.error("Context: " + sContext);
console.error(e);
CLIENT.users.get(MAIN.Config.bot.master_user_id).send(`Someone encountered an error from DiscordAPI...\nContext: ${context}\nError: ${e.message}`)
.then(() => Logger.log(1, 'Notified master about the error'))
.catch(console.error);
}
}
}
module.exports = Logger;
const MAIN = require('./server');
const CLIENT = require('./client');