diff --git a/src/main/java/com/Acrobot/ChestShop/ChestShop.java b/src/main/java/com/Acrobot/ChestShop/ChestShop.java index baa3ce2..5e237a2 100644 --- a/src/main/java/com/Acrobot/ChestShop/ChestShop.java +++ b/src/main/java/com/Acrobot/ChestShop/ChestShop.java @@ -118,6 +118,7 @@ public class ChestShop extends JavaPlugin { private static ItemDatabase itemDatabase; private static Logger logger; + private static Logger shopLogger; private FileHandler handler; private List commands = new ArrayList<>(); @@ -125,6 +126,8 @@ public class ChestShop extends JavaPlugin { public ChestShop() { dataFolder = getDataFolder(); logger = getLogger(); + shopLogger = Logger.getLogger("ChestShop Shops"); + shopLogger.setParent(logger); description = getDescription(); server = getServer(); plugin = this; @@ -165,20 +168,6 @@ public class ChestShop extends JavaPlugin { registerPluginMessagingChannels(); - if (Properties.LOG_TO_FILE) { - File log = loadFile("ChestShop.log"); - - FileHandler handler = loadHandler(log.getAbsolutePath()); - handler.setFormatter(new FileFormatter()); - - this.handler = handler; - logger.addHandler(handler); - } - - if (!Properties.LOG_TO_CONSOLE) { - logger.setUseParentHandlers(false); - } - startStatistics(); startBuildNotificatier(); startUpdater(); @@ -201,6 +190,22 @@ public class ChestShop extends JavaPlugin { NameManager.load(); commands.forEach(c -> c.setPermissionMessage(Messages.ACCESS_DENIED.getTextWithPrefix(null))); + + if (handler != null) { + shopLogger.removeHandler(handler); + } + + if (Properties.LOG_TO_FILE) { + if (handler == null) { + File log = loadFile("ChestShop.log"); + + handler = loadHandler(log.getAbsolutePath()); + handler.setFormatter(new FileFormatter()); + } + shopLogger.addHandler(handler); + } + + shopLogger.setUseParentHandlers(Properties.LOG_TO_CONSOLE); } private void turnOffDatabaseLogging() { @@ -559,6 +564,10 @@ public class ChestShop extends JavaPlugin { return dataFolder; } + public static Logger getShopLogger() { + return shopLogger; + } + public static Logger getBukkitLogger() { return logger; } diff --git a/src/main/java/com/Acrobot/ChestShop/Configuration/Properties.java b/src/main/java/com/Acrobot/ChestShop/Configuration/Properties.java index 72c95e3..cb2e7e7 100644 --- a/src/main/java/com/Acrobot/ChestShop/Configuration/Properties.java +++ b/src/main/java/com/Acrobot/ChestShop/Configuration/Properties.java @@ -255,10 +255,10 @@ public class Properties { @ConfigurationComment("If true, plugin will log transactions in its own file") public static boolean LOG_TO_FILE = false; - @ConfigurationComment("Do you want ChestShop's messages to show up in console?") + @ConfigurationComment("Do you want ChestShop's transaction messages to show up in console?") public static boolean LOG_TO_CONSOLE = true; - @ConfigurationComment("Should all shop removals be logged to the console?") + @ConfigurationComment("Should all shop removals be logged?") public static boolean LOG_ALL_SHOP_REMOVALS = true; @PrecededBySpace diff --git a/src/main/java/com/Acrobot/ChestShop/Listeners/PostShopCreation/ShopCreationLogger.java b/src/main/java/com/Acrobot/ChestShop/Listeners/PostShopCreation/ShopCreationLogger.java index 93f585c..4c6e9de 100644 --- a/src/main/java/com/Acrobot/ChestShop/Listeners/PostShopCreation/ShopCreationLogger.java +++ b/src/main/java/com/Acrobot/ChestShop/Listeners/PostShopCreation/ShopCreationLogger.java @@ -32,7 +32,7 @@ public class ShopCreationLogger implements Listener { prices, location); - ChestShop.getBukkitLogger().info(message); + ChestShop.getShopLogger().info(message); }); } } diff --git a/src/main/java/com/Acrobot/ChestShop/Listeners/PostTransaction/TransactionLogger.java b/src/main/java/com/Acrobot/ChestShop/Listeners/PostTransaction/TransactionLogger.java index 6ee86fd..eda7868 100644 --- a/src/main/java/com/Acrobot/ChestShop/Listeners/PostTransaction/TransactionLogger.java +++ b/src/main/java/com/Acrobot/ChestShop/Listeners/PostTransaction/TransactionLogger.java @@ -36,6 +36,6 @@ public class TransactionLogger implements Listener { event.getOwnerAccount().getName(), LocationUtil.locationToString(event.getSign().getLocation())); - ChestShop.getBukkitLogger().info(message); + ChestShop.getShopLogger().info(message); } } diff --git a/src/main/java/com/Acrobot/ChestShop/Listeners/ShopRemoval/ShopRemovalLogger.java b/src/main/java/com/Acrobot/ChestShop/Listeners/ShopRemoval/ShopRemovalLogger.java index ad0b04d..45f0456 100644 --- a/src/main/java/com/Acrobot/ChestShop/Listeners/ShopRemoval/ShopRemovalLogger.java +++ b/src/main/java/com/Acrobot/ChestShop/Listeners/ShopRemoval/ShopRemovalLogger.java @@ -17,7 +17,7 @@ public class ShopRemovalLogger implements Listener { @EventHandler(priority = EventPriority.MONITOR) public static void onShopRemoval(final ShopDestroyedEvent event) { - if (Properties.LOG_ALL_SHOP_REMOVALS || event.getDestroyer() != null) { + if (!Properties.LOG_ALL_SHOP_REMOVALS && event.getDestroyer() != null) { return; } @@ -36,7 +36,7 @@ public class ShopRemovalLogger implements Listener { prices, location); - ChestShop.getBukkitLogger().info(message); + ChestShop.getShopLogger().info(message); }); } }