From dd99d6563f0ee97e09137b4700ff1fb1d96237f2 Mon Sep 17 00:00:00 2001 From: beanbeanjuice Date: Mon, 22 Jul 2024 13:36:17 -0400 Subject: [PATCH] Fixed Shadowjar Twitch Issue --- build.gradle.kts | 11 +++-------- .../cafebot/utility/logging/LogManager.java | 7 +------ .../utility/sections/twitch/TwitchHandler.java | 3 +++ 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 1e5a7b54..55d2a3fe 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -88,8 +88,7 @@ dependencies { implementation("org.apache.logging.log4j", "log4j-api", "2.23.1") implementation("org.apache.logging.log4j", "log4j-core", "2.23.1") - implementation("org.slf4j", "slf4j-reload4j", "2.0.13") - implementation("org.apache.logging.log4j", "log4j-slf4j18-impl", "2.18.0") // JDA logs. + implementation("org.apache.logging.log4j", "log4j-slf4j2-impl", "2.23.1") // JDA logging. implementation("com.fasterxml.jackson.core:jackson-databind:2.17.1") @@ -105,13 +104,9 @@ dependencies { tasks.withType { minimize { exclude(dependency("io.github.xanthic.cache:.*:.*")) + exclude(dependency("org.apache.logging.log4j:.*:.*")) + exclude(dependency("com.github.twitch4j:.*:.*")) } - - relocate("net.dv8tion", "com.beanbeanjuice.cafebot.libs.net.dv8tion") - relocate("org.slf4j", "com.beanbeanjuice.cafebot.libs.org.slf4j") - relocate("org.apache.logging.log4j", "com.beanbeanjuice.cafebot.libs.org.apache.logging.log4j") - relocate("com.github.twitch4j", "com.beanbeanjuice.cafebot.libs.com.github.twitch4j") - relocate("com.fasterxml.jackson.core", "com.beanbeanjuice.cafebot.libs.com.fasterxml.jackson.core") } configure("processResources") { diff --git a/src/main/java/com/beanbeanjuice/cafebot/utility/logging/LogManager.java b/src/main/java/com/beanbeanjuice/cafebot/utility/logging/LogManager.java index 1dbdbb11..f28af0c7 100644 --- a/src/main/java/com/beanbeanjuice/cafebot/utility/logging/LogManager.java +++ b/src/main/java/com/beanbeanjuice/cafebot/utility/logging/LogManager.java @@ -19,12 +19,6 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; -/** - * A class used for logging. - * - * @author beanbeanjuice - * @since v3.0.1 - */ public class LogManager { private final Time time; @@ -323,6 +317,7 @@ public void log(@NotNull Class c, @NotNull LogLevel logLevel, @NotNull String checkFiles(); Logger logger = org.apache.logging.log4j.LogManager.getLogger(c); +// Logger logger = LoggerFactory.getLogger(c); switch (logLevel) { case INFO, LOADING, OKAY -> logger.info(message); diff --git a/src/main/java/com/beanbeanjuice/cafebot/utility/sections/twitch/TwitchHandler.java b/src/main/java/com/beanbeanjuice/cafebot/utility/sections/twitch/TwitchHandler.java index ff091507..1c6efd76 100644 --- a/src/main/java/com/beanbeanjuice/cafebot/utility/sections/twitch/TwitchHandler.java +++ b/src/main/java/com/beanbeanjuice/cafebot/utility/sections/twitch/TwitchHandler.java @@ -33,6 +33,9 @@ public void handleStartup(final CafeBot cafeBot) { this.addStream(channel); cafeBot.getLogger().log(TwitchHandler.class, LogLevel.DEBUG, String.format("Adding Twitch Channel: %s", channel), false, false); }); + }).exceptionallyAsync((e) -> { + cafeBot.getLogger().log(TwitchHandler.class, LogLevel.ERROR, String.format("Error Adding Twitch Channels: %s", e.getMessage()), e); + return null; }); }