mirror of
https://github.com/TheShadowEevee/Konpeki-Discord-Bot.git
synced 2025-01-11 22:38:50 -06:00
Allow for up to 2 lines of output for an error
This commit is contained in:
parent
dd882eb048
commit
2dd4b193aa
1 changed files with 11 additions and 1 deletions
|
@ -35,6 +35,9 @@ const colorText = function(message, color) {
|
||||||
|
|
||||||
// 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
|
||||||
|
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);
|
||||||
|
@ -46,7 +49,14 @@ const log = function(logLevel, message) {
|
||||||
console.log(datetime + ' ' + colorText('[WARN]', textColor.Yellow) + ' ' + message);
|
console.log(datetime + ' ' + colorText('[WARN]', textColor.Yellow) + ' ' + message);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
console.log(datetime + ' ' + colorText('[ERROR]', textColor.Red) + ' ' + message);
|
// 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());
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
console.log(datetime + ' ' + colorText('[INFO]', textColor.White) + ' ' + message);
|
console.log(datetime + ' ' + colorText('[INFO]', textColor.White) + ' ' + message);
|
||||||
|
|
Loading…
Reference in a new issue