mirror of
https://github.com/TheShadowEevee/Konpeki-Discord-Bot.git
synced 2025-01-11 14:38:49 -06:00
Formatting Pass 2 Electric Boogaloo
This commit is contained in:
parent
0e88fe0fce
commit
8650468bd9
2 changed files with 53 additions and 53 deletions
|
@ -7,21 +7,21 @@
|
||||||
|
|
||||||
// Enum list of severity levels
|
// Enum list of severity levels
|
||||||
const logLevels = {
|
const logLevels = {
|
||||||
DEBUG: 0,
|
DEBUG: 0,
|
||||||
INFO: 1,
|
INFO: 1,
|
||||||
WARN: 2,
|
WARN: 2,
|
||||||
ERROR: 3,
|
ERROR: 3,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Enum list of text colors
|
// Enum list of text colors
|
||||||
const textColor = {
|
const textColor = {
|
||||||
White: '\x1b[97m',
|
White: '\x1b[97m',
|
||||||
Gray: '\x1b[37m',
|
Gray: '\x1b[37m',
|
||||||
Yellow: '\x1b[33m',
|
Yellow: '\x1b[33m',
|
||||||
Red: '\x1b[91m',
|
Red: '\x1b[91m',
|
||||||
Blue: '\x1b[96m',
|
Blue: '\x1b[96m',
|
||||||
Green: '\x1b[92m',
|
Green: '\x1b[92m',
|
||||||
Reset: '\x1b[0m',
|
Reset: '\x1b[0m',
|
||||||
};
|
};
|
||||||
|
|
||||||
// Get the current Date and Time
|
// Get the current Date and Time
|
||||||
|
@ -30,43 +30,43 @@ const datetime = '[' + ('0' + (date_time.getMonth() + 1)).slice(-2) + '/' + ('0'
|
||||||
|
|
||||||
// Add color to the text passed through - If a text manip util is made, move this there
|
// Add color to the text passed through - If a text manip util is made, move this there
|
||||||
const colorText = function(message, color) {
|
const colorText = function(message, color) {
|
||||||
return color + message + textColor.Reset;
|
return color + message + textColor.Reset;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Print log message to console based on severity level
|
// Print log message to console based on severity level
|
||||||
const log = function(logLevel, message) {
|
const log = function(logLevel, message) {
|
||||||
// Used in the event the message is an error: see case 3
|
// Used in the event the message is an error: see case 3
|
||||||
const lines = message.toString().split('\n');
|
const lines = message.toString().split('\n');
|
||||||
|
|
||||||
switch (logLevel) {
|
switch (logLevel) {
|
||||||
case 0:
|
case 0:
|
||||||
console.log(datetime + ' ' + colorText('[DEBUG]', textColor.Gray) + ' ' + message);
|
console.log(datetime + ' ' + colorText('[DEBUG]', textColor.Gray) + ' ' + message);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
console.log(datetime + ' ' + colorText('[INFO]', textColor.White) + ' ' + message);
|
console.log(datetime + ' ' + colorText('[INFO]', textColor.White) + ' ' + message);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
console.log(datetime + ' ' + colorText('[WARN]', textColor.Yellow) + ' ' + message);
|
console.log(datetime + ' ' + colorText('[WARN]', textColor.Yellow) + ' ' + message);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
// Errors tend to have multiple lines, handle them specially to include the first two.
|
// Errors tend to have multiple lines, handle them specially to include the first two.
|
||||||
console.log(datetime + ' ' + colorText('[ERROR]', textColor.Red) + ' ' + lines[0]);
|
console.log(datetime + ' ' + colorText('[ERROR]', textColor.Red) + ' ' + lines[0]);
|
||||||
|
|
||||||
// If the error only has 1 line, don't try to read a second one
|
// If the error only has 1 line, don't try to read a second one
|
||||||
if (lines[1] != null) {
|
if (lines[1] != null) {
|
||||||
console.log(datetime + ' ' + colorText('[ERROR]', textColor.Red) + ' | ' + lines[1].trim());
|
console.log(datetime + ' ' + colorText('[ERROR]', textColor.Red) + ' | ' + lines[1].trim());
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
console.log(datetime + ' ' + colorText('[INFO]', textColor.White) + ' ' + message);
|
console.log(datetime + ' ' + colorText('[INFO]', textColor.White) + ' ' + message);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
logLevels,
|
logLevels,
|
||||||
textColor,
|
textColor,
|
||||||
colorText,
|
colorText,
|
||||||
log,
|
log,
|
||||||
};
|
};
|
|
@ -6,35 +6,35 @@
|
||||||
const io = require('@pm2/io');
|
const io = require('@pm2/io');
|
||||||
|
|
||||||
const interactionErrors = io.counter({
|
const interactionErrors = io.counter({
|
||||||
name: 'Interaction Errors (Since last restart)',
|
name: 'Interaction Errors (Since last restart)',
|
||||||
});
|
});
|
||||||
|
|
||||||
const interactionSuccessCounter = io.counter({
|
const interactionSuccessCounter = io.counter({
|
||||||
name: 'Interaction Successful Runs (Since last restart)',
|
name: 'Interaction Successful Runs (Since last restart)',
|
||||||
});
|
});
|
||||||
|
|
||||||
const interactionSuccessMeter = io.meter({
|
const interactionSuccessMeter = io.meter({
|
||||||
name: 'Successful Interactions per Second',
|
name: 'Successful Interactions per Second',
|
||||||
});
|
});
|
||||||
|
|
||||||
const websocketHeartbeatHist = io.histogram({
|
const websocketHeartbeatHist = io.histogram({
|
||||||
name: 'Avg. Websocket Heartbeat (ms) / 5 min.',
|
name: 'Avg. Websocket Heartbeat (ms) / 5 min.',
|
||||||
measurement: 'mean',
|
measurement: 'mean',
|
||||||
});
|
});
|
||||||
|
|
||||||
const serverCount = io.metric({
|
const serverCount = io.metric({
|
||||||
name : 'Server Count',
|
name : 'Server Count',
|
||||||
});
|
});
|
||||||
|
|
||||||
const interactionSuccess = function() {
|
const interactionSuccess = function() {
|
||||||
interactionSuccessCounter.inc();
|
interactionSuccessCounter.inc();
|
||||||
interactionSuccessMeter.mark();
|
interactionSuccessMeter.mark();
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
io,
|
io,
|
||||||
interactionErrors,
|
interactionErrors,
|
||||||
interactionSuccess,
|
interactionSuccess,
|
||||||
websocketHeartbeatHist,
|
websocketHeartbeatHist,
|
||||||
serverCount,
|
serverCount,
|
||||||
};
|
};
|
Loading…
Reference in a new issue