From 0690b30c023d8dc00d2e3b2a14db55a2e4688eb1 Mon Sep 17 00:00:00 2001 From: Tim203 Date: Sun, 15 Sep 2019 09:57:02 +0200 Subject: [PATCH] Made logging a bit more useful --- .../main/java/org/geysermc/api/logger/Logger.java | 10 ++++++++++ .../java/org/geysermc/connector/GeyserConnector.java | 2 +- .../org/geysermc/connector/console/GeyserLogger.java | 12 ++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/api/src/main/java/org/geysermc/api/logger/Logger.java b/api/src/main/java/org/geysermc/api/logger/Logger.java index 7643f2801..d6227c817 100644 --- a/api/src/main/java/org/geysermc/api/logger/Logger.java +++ b/api/src/main/java/org/geysermc/api/logger/Logger.java @@ -34,6 +34,11 @@ public interface Logger { */ void severe(String message); + /** + * Logs a severe message and an exception to console + */ + void severe(String message, Throwable error); + /** * Logs an error message to console * @@ -41,6 +46,11 @@ public interface Logger { */ void error(String message); + /** + * Logs an error message and an exception to console + */ + void error(String message, Throwable error); + /** * Logs a warning message to console * diff --git a/connector/src/main/java/org/geysermc/connector/GeyserConnector.java b/connector/src/main/java/org/geysermc/connector/GeyserConnector.java index bb2a0429e..a6f598d49 100644 --- a/connector/src/main/java/org/geysermc/connector/GeyserConnector.java +++ b/connector/src/main/java/org/geysermc/connector/GeyserConnector.java @@ -121,7 +121,7 @@ public class GeyserConnector implements Connector { config = FileUtils.loadConfig(configFile, GeyserConfiguration.class); } catch (IOException ex) { - logger.severe("Failed to read/create config.yml! Make sure it's up to date and/or readable+writable!"); + logger.severe("Failed to read/create config.yml! Make sure it's up to date and/or readable+writable!", ex); shutdown(); } diff --git a/connector/src/main/java/org/geysermc/connector/console/GeyserLogger.java b/connector/src/main/java/org/geysermc/connector/console/GeyserLogger.java index ece123d26..db31bfc18 100644 --- a/connector/src/main/java/org/geysermc/connector/console/GeyserLogger.java +++ b/connector/src/main/java/org/geysermc/connector/console/GeyserLogger.java @@ -93,12 +93,24 @@ public class GeyserLogger implements org.geysermc.api.logger.Logger { System.out.println(printConsole(ChatColor.DARK_RED + message, colored)); } + @Override + public void severe(String message, Throwable error) { + waitFor(); + System.out.println(printConsole(ChatColor.DARK_RED + message + "\n" + error.getMessage(), colored)); + } + @Override public void error(String message) { waitFor(); System.out.println(printConsole(ChatColor.RED + message, colored)); } + @Override + public void error(String message, Throwable error) { + waitFor(); + System.out.println(printConsole(ChatColor.RED + message + "\n" + error.getMessage(), colored)); + } + @Override public void warning(String message) { waitFor();