From 86eea54913bcdd0f50e1e2e4e10e0c3cec71dde9 Mon Sep 17 00:00:00 2001 From: Phoenix616 Date: Wed, 13 Mar 2024 13:43:09 +0100 Subject: [PATCH] Use slf4j logger instead of JUL This fixes logging issues in certain environments. Also replace stacktrace printing with logging it. --- src/main/java/net/azisaba/kuvel/Kuvel.java | 5 ++--- src/main/java/net/azisaba/kuvel/config/KuvelConfig.java | 5 +++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/net/azisaba/kuvel/Kuvel.java b/src/main/java/net/azisaba/kuvel/Kuvel.java index 84b3f11a..49dc1c54 100644 --- a/src/main/java/net/azisaba/kuvel/Kuvel.java +++ b/src/main/java/net/azisaba/kuvel/Kuvel.java @@ -14,7 +14,6 @@ import java.nio.file.Path; import java.util.Objects; import java.util.concurrent.TimeUnit; -import java.util.logging.Logger; import lombok.Getter; import net.azisaba.kuvel.config.KuvelConfig; import net.azisaba.kuvel.discovery.impl.redis.RedisLoadBalancerDiscovery; @@ -24,6 +23,7 @@ import net.azisaba.kuvel.redis.ProxyIdProvider; import net.azisaba.kuvel.redis.RedisConnectionLeader; import net.azisaba.kuvel.redis.RedisSubscriberExecutor; +import org.slf4j.Logger; @Plugin( id = "kuvel", @@ -63,8 +63,7 @@ public void onProxyInitialization(ProxyInitializeEvent event) { try { kuvelConfig.load(); } catch (Exception e) { - logger.severe("Failed to load config file. Plugin feature will be disabled."); - e.printStackTrace(); + logger.error("Failed to load config file. Plugin feature will be disabled.", e); return; } diff --git a/src/main/java/net/azisaba/kuvel/config/KuvelConfig.java b/src/main/java/net/azisaba/kuvel/config/KuvelConfig.java index 63ff5824..e6c528b0 100644 --- a/src/main/java/net/azisaba/kuvel/config/KuvelConfig.java +++ b/src/main/java/net/azisaba/kuvel/config/KuvelConfig.java @@ -38,7 +38,8 @@ public void load() throws IOException { } catch (NumberFormatException e) { plugin .getLogger() - .warning("Invalid port number for Redis connection specified in KUVEL_REDIS_CONNECTION_PORT environment variable. Using port " + port + " from config.yml."); + .warn( + "Invalid port number for Redis connection specified in KUVEL_REDIS_CONNECTION_PORT environment variable. Using port " + port + " from config.yml."); } } String username = env.getOrDefault("KUVEL_REDIS_CONNECTION_USERNAME", conf.getString("redis.connection.username")); @@ -48,7 +49,7 @@ public void load() throws IOException { redisEnabled = false; plugin .getLogger() - .warning( + .warn( "Redis is enabled, but hostname or port is invalid. Redis sync will be disabled."); } else { redisConnectionData = new RedisConnectionData(hostname, port, username, password);