Skip to content

Commit 076082d

Browse files
committed
Refactor Logging
1 parent 3eaf02f commit 076082d

39 files changed

+69
-96
lines changed

.eslintrc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,5 @@
2222
"no-constant-condition": ["error", { "checkLoops": false }],
2323
"import/extensions": ["warn", "always", { "ts": "never" }],
2424
"no-throw-literal": "error",
25-
"no-console": "error"
2625
}
2726
}

API/stats/bestiary.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
const { errorMessage } = require("../../src/Logger.js");
21
const constants = require("../constants/bestiary.js");
32

43
function formatBestiaryMobs(userProfile, mobs) {
@@ -73,7 +72,7 @@ function getBestiary(userProfile) {
7372
maxMilestone: totalTiers / 10,
7473
};
7574
} catch (error) {
76-
errorMessage(error);
75+
console.error(error);
7776
return null;
7877
}
7978
}

API/stats/chocolateFactory.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// CREDITS: by @Kathund (https://github.com/Kathund)
2-
const { errorMessage } = require("../../src/Logger.js");
32

43
module.exports = (profile) => {
54
try {
@@ -19,7 +18,7 @@ module.exports = (profile) => {
1918
level: profile.events?.easter?.chocolate_level || 0,
2019
};
2120
} catch (error) {
22-
errorMessage(error);
21+
console.error(error);
2322
return null;
2423
}
2524
};

API/stats/crimson.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// CREDITS: by @Kathund (https://github.com/Kathund)
22
const { titleCase } = require("../constants/functions.js");
3-
const { errorMessage } = require("../../src/Logger.js");
43

54
module.exports = (profile) => {
65
try {
@@ -62,7 +61,7 @@ module.exports = (profile) => {
6261
trophyFishing: getTrophyFish(profile),
6362
};
6463
} catch (error) {
65-
errorMessage(error);
64+
console.error(error);
6665
return null;
6766
}
6867
};

API/stats/dungeons.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
const calcSkill = require("../constants/skills.js");
22
const { titleCase } = require("../constants/functions.js");
3-
const { errorMessage } = require("../../src/Logger.js");
43

54
module.exports = (profile) => {
65
try {
@@ -96,7 +95,7 @@ module.exports = (profile) => {
9695
},
9796
};
9897
} catch (error) {
99-
errorMessage(error);
98+
console.error(error);
10099
return null;
101100
}
102101
};

API/stats/hotm.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// CREDITS: by @Kathund (https://github.com/Kathund)
22
const { titleCase } = require("../constants/functions.js");
3-
const { errorMessage } = require("../../src/Logger.js");
43
const miningConst = require("../constants/mining.js");
54
const calcSkill = require("../constants/skills.js");
65
const moment = require("moment");
@@ -52,7 +51,7 @@ module.exports = (player, profile) => {
5251
forgeItem.timeFinishedText =
5352
timeFinished < Date.now() ? "Finished" : `ending ${moment(timeFinished).fromNow()}`;
5453
} else {
55-
errorMessage(item);
54+
console.error(item);
5655
forgeItem.name = "Unknown Item";
5756
forgeItem.id = `UNKNOWN-${item.id}`;
5857
}
@@ -85,7 +84,7 @@ module.exports = (player, profile) => {
8584
forge: forgeItems,
8685
};
8786
} catch (error) {
88-
errorMessage(error);
87+
console.error(error);
8988
return null;
9089
}
9190
};

API/stats/talismans.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
const { decodeData } = require("../../src/contracts/helperFunctions.js");
22
const { titleCase } = require("../constants/functions.js");
3-
const { errorMessage } = require("../../src/Logger.js");
43

54
module.exports = async (profile) => {
65
try {
@@ -76,7 +75,7 @@ module.exports = async (profile) => {
7675
return null;
7776
}
7877
} catch (error) {
79-
errorMessage(error);
78+
console.error(error);
8079
return null;
8180
}
8281
};

src/Application.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ class Application {
77
constructor() {
88
require("./Configuration.js");
99
require("./Updater.js");
10+
require("./Logger.js");
1011
if (!existsSync("./data/")) mkdirSync("./data/", { recursive: true });
1112
if (!existsSync("./data/linked.json")) writeFileSync("./data/linked.json", JSON.stringify({}));
1213
}

src/Logger.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -175,13 +175,14 @@ async function updateMessage() {
175175
console.log(chalk.bgRed.black(" ".repeat(columns).repeat(3)));
176176
}
177177

178+
console.discord = discordMessage;
179+
console.minecraft = minecraftMessage;
180+
console.web = webMessage;
181+
console.warn = warnMessage;
182+
console.error = errorMessage;
183+
console.broadcast = broadcastMessage;
184+
178185
module.exports = {
179-
discordMessage,
180-
minecraftMessage,
181-
webMessage,
182-
warnMessage,
183-
errorMessage,
184-
broadcastMessage,
185186
getCurrentTime,
186187
configUpdateMessage,
187188
updateMessage,

src/Updater.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ function updateCode() {
1010

1111
exec("git pull", (error, stdout, stderr) => {
1212
if (error) {
13-
Logger.errorMessage(error);
13+
Logger.console.error(error);
1414
return;
1515
}
1616

0 commit comments

Comments
 (0)