From 3ff12f6bf52268b228aadbfbe634ca9ab0c135b6 Mon Sep 17 00:00:00 2001 From: drtshock Date: Thu, 2 May 2013 22:19:28 -0500 Subject: More logging! --- .../src/net/ess3/xmpp/EssentialsXMPP.java | 3 +-- EssentialsXMPP/src/net/ess3/xmpp/XMPPManager.java | 24 +++++++++++----------- 2 files changed, 13 insertions(+), 14 deletions(-) (limited to 'EssentialsXMPP/src') diff --git a/EssentialsXMPP/src/net/ess3/xmpp/EssentialsXMPP.java b/EssentialsXMPP/src/net/ess3/xmpp/EssentialsXMPP.java index e89d142da..75ee46542 100644 --- a/EssentialsXMPP/src/net/ess3/xmpp/EssentialsXMPP.java +++ b/EssentialsXMPP/src/net/ess3/xmpp/EssentialsXMPP.java @@ -18,7 +18,6 @@ import org.bukkit.plugin.java.JavaPlugin; public class EssentialsXMPP extends JavaPlugin implements IEssentialsXMPP { - private static final Logger LOGGER = Logger.getLogger("Minecraft"); private static EssentialsXMPP instance = null; private UserManager users; private XMPPManager xmpp; @@ -40,7 +39,7 @@ public class EssentialsXMPP extends JavaPlugin implements IEssentialsXMPP ess = plugin.getEssentials(); if (!this.getDescription().getVersion().equals(plugin.getDescription().getVersion())) { - LOGGER.log(Level.WARNING, _("§4Version mismatch! Please update all Essentials jars to the same version.")); + getLogger().log(Level.WARNING, _("§4Version mismatch! Please update all Essentials jars to the same version.")); } if (!plugin.isEnabled()) { diff --git a/EssentialsXMPP/src/net/ess3/xmpp/XMPPManager.java b/EssentialsXMPP/src/net/ess3/xmpp/XMPPManager.java index 34d98cb11..8097a992f 100644 --- a/EssentialsXMPP/src/net/ess3/xmpp/XMPPManager.java +++ b/EssentialsXMPP/src/net/ess3/xmpp/XMPPManager.java @@ -3,6 +3,7 @@ package net.ess3.xmpp; import java.io.File; import java.util.*; import java.util.logging.*; +import net.ess3.api.IEssentials; import net.ess3.api.IReload; import net.ess3.api.IUser; import net.ess3.utils.FormatUtil; @@ -17,7 +18,6 @@ import org.jivesoftware.smack.util.StringUtils; public final class XMPPManager extends Handler implements MessageListener, ChatManagerListener, IReload { - private static final Logger LOGGER = Logger.getLogger("Minecraft"); private static final SimpleFormatter formatter = new SimpleFormatter(); private YamlConfiguration config = null; private XMPPConnection connection; @@ -98,7 +98,7 @@ public final class XMPPManager extends Handler implements MessageListener, ChatM final String server = config.getString("xmpp.server"); if (server == null || server.equals("example.com")) { - LOGGER.log(Level.WARNING, "config broken for xmpp"); + parent.getLogger().log(Level.WARNING, "config broken for xmpp"); return false; } final int port = config.getInt("xmpp.port", 5222); @@ -109,7 +109,7 @@ public final class XMPPManager extends Handler implements MessageListener, ChatM final StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append("Connecting to xmpp server ").append(server).append(":").append(port); stringBuilder.append(" as user ").append(xmppuser).append("."); - LOGGER.log(Level.INFO, stringBuilder.toString()); + parent.getLogger().log(Level.INFO, stringBuilder.toString()); connConf.setSASLAuthenticationEnabled(config.getBoolean("xmpp.sasl-enabled", false)); connConf.setSendPresence(true); connConf.setReconnectionAllowed(true); @@ -125,7 +125,7 @@ public final class XMPPManager extends Handler implements MessageListener, ChatM } catch (XMPPException ex) { - LOGGER.log(Level.WARNING, "Failed to connect to server: " + server, ex); + parent.getLogger().log(Level.WARNING, "Failed to connect to server: " + server, ex); return false; } } @@ -165,7 +165,7 @@ public final class XMPPManager extends Handler implements MessageListener, ChatM @Override public void onReload() { - LOGGER.removeHandler(this); + parent.getLogger().removeHandler(this); config = YamlConfiguration.loadConfiguration(new File(parent.getDataFolder(), "config.yml")); synchronized (chats) { @@ -179,7 +179,7 @@ public final class XMPPManager extends Handler implements MessageListener, ChatM } if (config.getBoolean("log-enabled", false)) { - LOGGER.addHandler(this); + parent.getLogger().addHandler(this); logUsers = config.getStringList("log-users"); final String level = config.getString("log-level", "info"); try @@ -271,14 +271,14 @@ public final class XMPPManager extends Handler implements MessageListener, ChatM catch (XMPPException ex) { failedUsers.add(user); - LOGGER.removeHandler(XMPPManager.this); - LOGGER.log(Level.SEVERE, "Failed to deliver log message! Disabling logging to XMPP.", ex); + parent.getLogger().removeHandler(XMPPManager.this); + parent.getLogger().log(Level.SEVERE, "Failed to deliver log message! Disabling logging to XMPP.", ex); } } logUsers.removeAll(failedUsers); if (logUsers.isEmpty()) { - LOGGER.removeHandler(XMPPManager.this); + parent.getLogger().removeHandler(XMPPManager.this); threadrunning = false; } copy.clear(); @@ -292,7 +292,7 @@ public final class XMPPManager extends Handler implements MessageListener, ChatM threadrunning = false; } } - LOGGER.removeHandler(XMPPManager.this); + parent.getLogger().removeHandler(XMPPManager.this); } }); loggerThread.start(); @@ -333,7 +333,7 @@ public final class XMPPManager extends Handler implements MessageListener, ChatM } catch (XMPPException ex) { - LOGGER.log(Level.WARNING, "Failed to send xmpp message.", ex); + parent.getLogger().log(Level.WARNING, "Failed to send xmpp message.", ex); } } else @@ -357,7 +357,7 @@ public final class XMPPManager extends Handler implements MessageListener, ChatM } catch (Exception ex) { - LOGGER.log(Level.SEVERE, ex.getMessage(), ex); + parent.getLogger().log(Level.SEVERE, ex.getMessage(), ex); } } } -- cgit v1.2.3