From 31446070b83d3db1ddd8fc318a101e95f28eb139 Mon Sep 17 00:00:00 2001 From: efekos <56752400+efekos@users.noreply.github.com> Date: Sat, 17 Aug 2024 16:05:50 +0300 Subject: [PATCH 1/2] switch to slf4j logging --- src/main/java/gg/flyte/neptune/Neptune.java | 5 ++--- .../neptune/command/CommandDispatcher.java | 5 +++-- .../flyte/neptune/command/CommandManager.java | 5 +++-- .../flyte/neptune/command/CommandMapping.java | 6 ++++-- .../java/gg/flyte/neptune/util/Logger.java | 19 ------------------- 5 files changed, 12 insertions(+), 28 deletions(-) delete mode 100644 src/main/java/gg/flyte/neptune/util/Logger.java diff --git a/src/main/java/gg/flyte/neptune/Neptune.java b/src/main/java/gg/flyte/neptune/Neptune.java index 3652371..f16cf78 100644 --- a/src/main/java/gg/flyte/neptune/Neptune.java +++ b/src/main/java/gg/flyte/neptune/Neptune.java @@ -2,11 +2,10 @@ import gg.flyte.neptune.command.CommandDispatcher; import gg.flyte.neptune.command.CommandManager; -import gg.flyte.neptune.util.Logger; import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.entities.Guild; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.slf4j.LoggerFactory; import java.io.IOException; import java.lang.reflect.InvocationTargetException; @@ -15,7 +14,7 @@ import java.util.List; public final class Neptune { - public static final @NotNull Logger LOGGER = new Logger(); + public static final @NotNull org.slf4j.Logger LOGGER = LoggerFactory.getLogger(Neptune.class); private final @NotNull JDA jda; private final @NotNull CommandManager manager; diff --git a/src/main/java/gg/flyte/neptune/command/CommandDispatcher.java b/src/main/java/gg/flyte/neptune/command/CommandDispatcher.java index bd1303c..476c38c 100644 --- a/src/main/java/gg/flyte/neptune/command/CommandDispatcher.java +++ b/src/main/java/gg/flyte/neptune/command/CommandDispatcher.java @@ -17,6 +17,8 @@ import org.reflections.scanners.ResourcesScanner; import org.reflections.scanners.SubTypesScanner; import org.reflections.util.ConfigurationBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.IOException; import java.lang.reflect.Field; @@ -25,13 +27,12 @@ import java.util.*; import java.util.stream.Collectors; -import static gg.flyte.neptune.Neptune.LOGGER; - public final class CommandDispatcher { private final @NotNull JDA jda; private final @NotNull CommandManager commandManager; private final @NotNull List guilds; private final boolean registerAllListeners; + private static final Logger LOGGER = LoggerFactory.getLogger(CommandDispatcher.class); public CommandDispatcher(@NotNull JDA jda, Object mainClass, @NotNull CommandManager commandManager, @NotNull List guilds, boolean clearCommands, boolean registerAllListeners) throws InstantiationException, IllegalAccessException, InvocationTargetException, IOException, ClassNotFoundException, NoSuchMethodException { LOGGER.debug("Instantiating dispatcher..."); diff --git a/src/main/java/gg/flyte/neptune/command/CommandManager.java b/src/main/java/gg/flyte/neptune/command/CommandManager.java index 4108dc1..d7790c3 100644 --- a/src/main/java/gg/flyte/neptune/command/CommandManager.java +++ b/src/main/java/gg/flyte/neptune/command/CommandManager.java @@ -5,14 +5,15 @@ import net.dv8tion.jda.api.hooks.ListenerAdapter; import net.dv8tion.jda.api.interactions.commands.OptionMapping; import org.jetbrains.annotations.NotNull; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.HashMap; import java.util.Map; -import static gg.flyte.neptune.Neptune.LOGGER; - public final class CommandManager extends ListenerAdapter { private final @NotNull Map commands = new HashMap<>(); + private static final Logger LOGGER = LoggerFactory.getLogger(CommandManager.class); public void addCommand(String command, CommandMapping mapping) { commands.put(command, mapping); diff --git a/src/main/java/gg/flyte/neptune/command/CommandMapping.java b/src/main/java/gg/flyte/neptune/command/CommandMapping.java index 0e1e92f..c2d4beb 100644 --- a/src/main/java/gg/flyte/neptune/command/CommandMapping.java +++ b/src/main/java/gg/flyte/neptune/command/CommandMapping.java @@ -7,18 +7,20 @@ import gg.flyte.neptune.annotation.Optional; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.lang.reflect.Method; import java.lang.reflect.Parameter; -import static gg.flyte.neptune.Neptune.LOGGER; - public final class CommandMapping { private final @NotNull Method method; private final @NotNull Object classInstance; private final @NotNull NamedParameter[] parameters; + private static final Logger LOGGER = LoggerFactory.getLogger(CommandMapping.class); + public CommandMapping(@NotNull Method method, @NotNull Object classInstance) { this.method = method; this.classInstance = classInstance; diff --git a/src/main/java/gg/flyte/neptune/util/Logger.java b/src/main/java/gg/flyte/neptune/util/Logger.java deleted file mode 100644 index 40f2b29..0000000 --- a/src/main/java/gg/flyte/neptune/util/Logger.java +++ /dev/null @@ -1,19 +0,0 @@ -package gg.flyte.neptune.util; - -public final class Logger { - public void debug(String... strings) { - for (String string : strings) System.out.println("[Neptune] DEBUG: " + string); - } - - public void info(String... strings) { - for (String string : strings) System.out.println("[Neptune] INFO: " + string); - } - - public void warn(String... strings) { - for (String string : strings) System.out.println("[Neptune] WARN: " + string); - } - - public void error(String... strings) { - for (String string : strings) System.out.println("[Neptune] ERROR: " + string); - } -} From e4389229080e294f535715532e748a8648490ad4 Mon Sep 17 00:00:00 2001 From: efekos <56752400+efekos@users.noreply.github.com> Date: Sat, 17 Aug 2024 16:07:29 +0300 Subject: [PATCH 2/2] how did this happen what --- src/main/java/gg/flyte/neptune/Neptune.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/gg/flyte/neptune/Neptune.java b/src/main/java/gg/flyte/neptune/Neptune.java index f16cf78..1370bef 100644 --- a/src/main/java/gg/flyte/neptune/Neptune.java +++ b/src/main/java/gg/flyte/neptune/Neptune.java @@ -5,6 +5,7 @@ import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.entities.Guild; import org.jetbrains.annotations.NotNull; +import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.IOException; @@ -14,7 +15,7 @@ import java.util.List; public final class Neptune { - public static final @NotNull org.slf4j.Logger LOGGER = LoggerFactory.getLogger(Neptune.class); + public static final @NotNull Logger LOGGER = LoggerFactory.getLogger(Neptune.class); private final @NotNull JDA jda; private final @NotNull CommandManager manager;