From 8650468bd90db35adc2fa0810f002ef239e0afc5 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 13 Sep 2023 08:41:47 -0400 Subject: [PATCH] Formatting Pass 2 Electric Boogaloo --- utils/logging.js | 80 ++++++++++++++++++++++---------------------- utils/pm2-metrics.js | 26 +++++++------- 2 files changed, 53 insertions(+), 53 deletions(-) diff --git a/utils/logging.js b/utils/logging.js index bc93f03..efa6c36 100644 --- a/utils/logging.js +++ b/utils/logging.js @@ -7,21 +7,21 @@ // Enum list of severity levels const logLevels = { - DEBUG: 0, - INFO: 1, - WARN: 2, - ERROR: 3, + DEBUG: 0, + INFO: 1, + WARN: 2, + ERROR: 3, }; // Enum list of text colors const textColor = { - White: '\x1b[97m', - Gray: '\x1b[37m', - Yellow: '\x1b[33m', - Red: '\x1b[91m', - Blue: '\x1b[96m', - Green: '\x1b[92m', - Reset: '\x1b[0m', + White: '\x1b[97m', + Gray: '\x1b[37m', + Yellow: '\x1b[33m', + Red: '\x1b[91m', + Blue: '\x1b[96m', + Green: '\x1b[92m', + Reset: '\x1b[0m', }; // 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 const colorText = function(message, color) { - return color + message + textColor.Reset; + return color + message + textColor.Reset; }; // Print log message to console based on severity level const log = function(logLevel, message) { - // Used in the event the message is an error: see case 3 - const lines = message.toString().split('\n'); + // Used in the event the message is an error: see case 3 + const lines = message.toString().split('\n'); - switch (logLevel) { - case 0: - console.log(datetime + ' ' + colorText('[DEBUG]', textColor.Gray) + ' ' + message); - break; - case 1: - console.log(datetime + ' ' + colorText('[INFO]', textColor.White) + ' ' + message); - break; - case 2: - console.log(datetime + ' ' + colorText('[WARN]', textColor.Yellow) + ' ' + message); - break; - case 3: - // Errors tend to have multiple lines, handle them specially to include the first two. - console.log(datetime + ' ' + colorText('[ERROR]', textColor.Red) + ' ' + lines[0]); + switch (logLevel) { + case 0: + console.log(datetime + ' ' + colorText('[DEBUG]', textColor.Gray) + ' ' + message); + break; + case 1: + console.log(datetime + ' ' + colorText('[INFO]', textColor.White) + ' ' + message); + break; + case 2: + console.log(datetime + ' ' + colorText('[WARN]', textColor.Yellow) + ' ' + message); + break; + case 3: + // Errors tend to have multiple lines, handle them specially to include the first two. + 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 (lines[1] != null) { - console.log(datetime + ' ' + colorText('[ERROR]', textColor.Red) + ' | ' + lines[1].trim()); - } + // If the error only has 1 line, don't try to read a second one + if (lines[1] != null) { + console.log(datetime + ' ' + colorText('[ERROR]', textColor.Red) + ' | ' + lines[1].trim()); + } - break; - default: - console.log(datetime + ' ' + colorText('[INFO]', textColor.White) + ' ' + message); - break; - } + break; + default: + console.log(datetime + ' ' + colorText('[INFO]', textColor.White) + ' ' + message); + break; + } }; module.exports = { - logLevels, - textColor, - colorText, - log, + logLevels, + textColor, + colorText, + log, }; \ No newline at end of file diff --git a/utils/pm2-metrics.js b/utils/pm2-metrics.js index 5e5bdaf..8cad521 100644 --- a/utils/pm2-metrics.js +++ b/utils/pm2-metrics.js @@ -6,35 +6,35 @@ const io = require('@pm2/io'); const interactionErrors = io.counter({ - name: 'Interaction Errors (Since last restart)', + name: 'Interaction Errors (Since last restart)', }); const interactionSuccessCounter = io.counter({ - name: 'Interaction Successful Runs (Since last restart)', + name: 'Interaction Successful Runs (Since last restart)', }); const interactionSuccessMeter = io.meter({ - name: 'Successful Interactions per Second', + name: 'Successful Interactions per Second', }); const websocketHeartbeatHist = io.histogram({ - name: 'Avg. Websocket Heartbeat (ms) / 5 min.', - measurement: 'mean', + name: 'Avg. Websocket Heartbeat (ms) / 5 min.', + measurement: 'mean', }); const serverCount = io.metric({ - name : 'Server Count', + name : 'Server Count', }); const interactionSuccess = function() { - interactionSuccessCounter.inc(); - interactionSuccessMeter.mark(); + interactionSuccessCounter.inc(); + interactionSuccessMeter.mark(); }; module.exports = { - io, - interactionErrors, - interactionSuccess, - websocketHeartbeatHist, - serverCount, + io, + interactionErrors, + interactionSuccess, + websocketHeartbeatHist, + serverCount, }; \ No newline at end of file