1
0
mirror of https://github.com/essentials/Essentials.git synced 2025-08-15 19:14:18 +02:00

Use proper logging.

This commit is contained in:
drtshock
2013-05-02 14:21:30 -05:00
parent fa7d89a5e9
commit f326d0ad0c
9 changed files with 34 additions and 33 deletions

View File

@@ -126,7 +126,7 @@ public class I18n implements II18n
currentLocale = new Locale(parts[0], parts[1], parts[2]);
}
ResourceBundle.clearCache();
Logger.getLogger("Minecraft").log(Level.INFO, String.format("Using locale %s", currentLocale.toString()));
ess.getLogger().log(Level.INFO, String.format("Using locale %s", currentLocale.toString()));
customBundle = ResourceBundle.getBundle(MESSAGES, currentLocale, new FileResClassLoader(I18n.class.getClassLoader(), ess));
localeBundle = ResourceBundle.getBundle(MESSAGES, currentLocale);
}

View File

@@ -30,7 +30,6 @@ import org.bukkit.plugin.PluginManager;
public class Jails extends AsyncStorageObjectHolder<net.ess3.settings.Jails> implements IJails
{
private static final Logger LOGGER = Bukkit.getLogger();
public Jails(final IEssentials ess)
{
@@ -174,11 +173,11 @@ public class Jails extends AsyncStorageObjectHolder<net.ess3.settings.Jails> imp
{
if (ess.getSettings().isDebug())
{
LOGGER.log(Level.INFO, _("§4Error occurred when trying to return player§c {0} §4to jail: {1}!", user.getName(), ex.getLocalizedMessage()), ex);
ess.getLogger().log(Level.INFO, _("§4Error occurred when trying to return player§c {0} §4to jail: {1}!", user.getName(), ex.getLocalizedMessage()), ex);
}
else
{
LOGGER.log(Level.INFO, _("§4Error occurred when trying to return player§c {0} §4to jail: {1}!", user.getName(), ex.getLocalizedMessage()));
ess.getLogger().log(Level.INFO, _("§4Error occurred when trying to return player§c {0} §4to jail: {1}!", user.getName(), ex.getLocalizedMessage()));
}
}
}
@@ -200,11 +199,11 @@ public class Jails extends AsyncStorageObjectHolder<net.ess3.settings.Jails> imp
{
if (ess.getSettings().isDebug())
{
LOGGER.log(Level.INFO, _("§4Error occurred when trying to return player§c {0} §4to jail: {1}!", user.getName(), ex.getLocalizedMessage()), ex);
ess.getLogger().log(Level.INFO, _("§4Error occurred when trying to return player§c {0} §4to jail: {1}!", user.getName(), ex.getLocalizedMessage()), ex);
}
else
{
LOGGER.log(Level.INFO, _("§4Error occurred when trying to return player§c {0} §4to jail: {1}!", user.getName(), ex.getLocalizedMessage()));
ess.getLogger().log(Level.INFO, _("§4Error occurred when trying to return player§c {0} §4to jail: {1}!", user.getName(), ex.getLocalizedMessage()));
}
}
user.sendMessage(_("§4You do the crime, you do the time."));
@@ -227,11 +226,11 @@ public class Jails extends AsyncStorageObjectHolder<net.ess3.settings.Jails> imp
{
if (ess.getSettings().isDebug())
{
LOGGER.log(Level.INFO, _("§4Error occurred when trying to return player§c {0} §4to jail: {1}!", user.getName(), ex.getLocalizedMessage()), ex);
ess.getLogger().log(Level.INFO, _("§4Error occurred when trying to return player§c {0} §4to jail: {1}!", user.getName(), ex.getLocalizedMessage()), ex);
}
else
{
LOGGER.log(Level.INFO, _("§4Error occurred when trying to return player§c {0} §4to jail: {1}!", user.getName(), ex.getLocalizedMessage()));
ess.getLogger().log(Level.INFO, _("§4Error occurred when trying to return player§c {0} §4to jail: {1}!", user.getName(), ex.getLocalizedMessage()));
}
}
user.sendMessage(_("§4You do the crime, you do the time."));

View File

@@ -17,7 +17,6 @@ public class EssentialsCommandHandler implements ICommandHandler, TabExecutor
private final ClassLoader classLoader;
private final String commandPath;
private final String permissionPrefix;// TODO: Needed?
private static final Logger LOGGER = Bukkit.getLogger();
private final Map<String, List<PluginCommand>> altcommands = new HashMap<String, List<PluginCommand>>();
private final Map<String, String> disabledList = new HashMap<String, String>();
private final Map<String, IEssentialsCommand> commands = new HashMap<String, IEssentialsCommand>();
@@ -106,7 +105,7 @@ public class EssentialsCommandHandler implements ICommandHandler, TabExecutor
catch (Exception ex)
{
sender.sendMessage(_("§4Command {0} is improperly loaded.", commandName));
LOGGER.log(Level.SEVERE, _("§4Command {0} is improperly loaded.", commandName), ex);
ess.getLogger().log(Level.SEVERE, _("§4Command {0} is improperly loaded.", commandName), ex);
return true;
}
}
@@ -114,7 +113,7 @@ public class EssentialsCommandHandler implements ICommandHandler, TabExecutor
// Check authorization
if (sender != null && !cmd.isAuthorized(sender))
{
LOGGER.log(Level.WARNING, _("§c{0} §4was denied access to command.", sender.getName()));
ess.getLogger().log(Level.WARNING, _("§c{0} §4was denied access to command.", sender.getName()));
sender.sendMessage(_("§4You do not have access to that command."));
return true;
}
@@ -163,7 +162,7 @@ public class EssentialsCommandHandler implements ICommandHandler, TabExecutor
}
catch (Exception ex)
{
LOGGER.log(Level.SEVERE, _("Command {0} failed:", commandLabel), ex);
ess.getLogger().log(Level.SEVERE, _("Command {0} failed:", commandLabel), ex);
return true;
}
}
@@ -237,7 +236,7 @@ public class EssentialsCommandHandler implements ICommandHandler, TabExecutor
catch (Exception ex)
{
sender.sendMessage(_("§4Command {0} is improperly loaded.", commandName));
LOGGER.log(Level.SEVERE, _("§4Command {0} is improperly loaded.", commandName), ex);
ess.getLogger().log(Level.SEVERE, _("§4Command {0} is improperly loaded.", commandName), ex);
return null;
}
}
@@ -245,7 +244,7 @@ public class EssentialsCommandHandler implements ICommandHandler, TabExecutor
// Check authorization
if (sender != null && !cmd.isAuthorized(sender))
{
LOGGER.log(Level.WARNING, _("§c{0} §4was denied access to command.", sender.getName()));
ess.getLogger().log(Level.WARNING, _("§c{0} §4was denied access to command.", sender.getName()));
sender.sendMessage(_("§4You do not have access to that command."));
return null;
}
@@ -279,7 +278,7 @@ public class EssentialsCommandHandler implements ICommandHandler, TabExecutor
}
catch (Exception ex)
{
LOGGER.log(Level.SEVERE, _("Command {0} failed:", commandLabel), ex);
ess.getLogger().log(Level.SEVERE, _("Command {0} failed:", commandLabel), ex);
return null;
}
}
@@ -290,7 +289,7 @@ public class EssentialsCommandHandler implements ICommandHandler, TabExecutor
sender.sendMessage(_("§cError:§4 {0}", exception.getMessage()));
if (ess.getSettings().isDebug())
{
LOGGER.log(Level.WARNING, _("Error calling command /{0}", commandLabel), exception);
ess.getLogger().log(Level.WARNING, _("Error calling command /{0}", commandLabel), exception);
}
}
@@ -400,7 +399,7 @@ public class EssentialsCommandHandler implements ICommandHandler, TabExecutor
final String altString = pc.getPlugin().getName() + ":" + pc.getLabel();
if (ess.getSettings().isDebug())
{
LOGGER.log(Level.INFO, "Essentials: Alternative command " + label + " found, using " + altString); //TODO: TL key?
ess.getLogger().log(Level.INFO, "Essentials: Alternative command " + label + " found, using " + altString); //TODO: TL key?
}
disabledList.put(label, altString);
}

View File

@@ -39,7 +39,6 @@ import org.bukkit.inventory.ItemStack;
public class EssentialsPlayerListener implements Listener
{
private static final Logger LOGGER = Logger.getLogger("Minecraft");
private final Server server;
private final IEssentials ess;
private final IUserMap userMap;
@@ -73,7 +72,7 @@ public class EssentialsPlayerListener implements Listener
{
event.setCancelled(true);
user.sendMessage(_("§6You have been muted!"));
LOGGER.info(_("{0} tried to speak, but is muted.", user.getName()));
ess.getLogger().info(_("{0} tried to speak, but is muted.", user.getName()));
}
final Iterator<Player> it = event.getRecipients().iterator();
while (it.hasNext())
@@ -306,11 +305,11 @@ public class EssentialsPlayerListener implements Listener
{
if (ess.getSettings().isDebug())
{
LOGGER.log(Level.WARNING, ex.getMessage(), ex);
ess.getLogger().log(Level.WARNING, ex.getMessage(), ex);
}
else
{
LOGGER.log(Level.WARNING, ex.getMessage());
ess.getLogger().log(Level.WARNING, ex.getMessage());
}
}
}

View File

@@ -56,7 +56,7 @@ public abstract class AbstractDelayedYamlFileReader<T extends StorageObject> imp
}
catch (IOException ex)
{
Bukkit.getLogger().log(Level.SEVERE, "File can't be closed: " + file.toString(), ex);
ess.getLogger().log(Level.SEVERE, "File can't be closed: " + file.toString(), ex);
}
}
@@ -64,14 +64,14 @@ public abstract class AbstractDelayedYamlFileReader<T extends StorageObject> imp
catch (FileNotFoundException ex)
{
onException(ex);
Bukkit.getLogger().log(Level.INFO, "File not found: " + file.toString());
ess.getLogger().log(Level.INFO, "File not found: " + file.toString());
}
catch (ObjectLoadException ex)
{
onException(ex);
File broken = new File(file.getAbsolutePath() + ".broken." + System.currentTimeMillis());
file.renameTo(broken);
Bukkit.getLogger().log(Level.SEVERE, "The file " + file.toString() + " is broken, it has been renamed to " + broken.toString(), ex.getCause());
ess.getLogger().log(Level.SEVERE, "The file " + file.toString() + " is broken, it has been renamed to " + broken.toString(), ex.getCause());
}
}
}

View File

@@ -48,7 +48,7 @@ public abstract class AbstractDelayedYamlFileWriter implements Runnable
}
catch (FileNotFoundException ex)
{
Bukkit.getLogger().log(Level.SEVERE, file.toString(), ex);
ess.getLogger().log(Level.SEVERE, file.toString(), ex);
}
finally
{

View File

@@ -32,7 +32,7 @@ public abstract class AsyncStorageObjectHolder<T extends StorageObject> implemen
}
catch (Exception ex)
{
Bukkit.getLogger().log(Level.SEVERE, ex.getMessage(), ex);
ess.getLogger().log(Level.SEVERE, ex.getMessage(), ex);
}
}
@@ -175,7 +175,7 @@ public abstract class AsyncStorageObjectHolder<T extends StorageObject> implemen
}
catch (Exception ex)
{
Bukkit.getLogger().log(Level.SEVERE, ex.getMessage(), ex);
ess.getLogger().log(Level.SEVERE, ex.getMessage(), ex);
}
}
loaded.set(true);

View File

@@ -19,9 +19,11 @@ public class ManagedFile
{
private final static int BUFFERSIZE = 1024 * 8;
private final File file;
protected final IEssentials ess;
public ManagedFile(final String filename, final IEssentials ess)
{
this.ess = ess;
file = new File(ess.getPlugin().getDataFolder(), filename);
if (file.exists())
@@ -35,7 +37,7 @@ public class ManagedFile
}
catch (IOException ex)
{
Bukkit.getLogger().log(Level.SEVERE, ex.getMessage(), ex);
ess.getLogger().log(Level.SEVERE, ex.getMessage(), ex);
}
}
@@ -47,7 +49,7 @@ public class ManagedFile
}
catch (IOException ex)
{
Bukkit.getLogger().log(Level.SEVERE, _("Could not load items.csv!"), ex);
ess.getLogger().log(Level.SEVERE, _("Could not load items.csv!"), ex);
}
}
}
@@ -157,7 +159,8 @@ public class ManagedFile
else
{
Bukkit.getLogger().warning(
"File " + file.toString() + " has been modified by user and file version differs, please update the file manually.");
"File " + file.toString() + " has been modified by user and file version "
+ "differs, please update the file manually.");
}
}
finally
@@ -222,7 +225,7 @@ public class ManagedFile
}
catch (IOException ex)
{
Bukkit.getLogger().log(Level.SEVERE, ex.getMessage(), ex);
ess.getLogger().log(Level.SEVERE, ex.getMessage(), ex);
return Collections.emptyList();
}
}

View File

@@ -15,16 +15,17 @@ import org.bukkit.plugin.PluginDescriptionFile;
public class HelpInput implements IText
{
protected final IEssentials ess;
private static final String DESCRIPTION = "description";
private static final String PERMISSION = "permission";
private static final String PERMISSIONS = "permissions";
private final List<String> lines = new ArrayList<String>();
private final List<String> chapters = new ArrayList<String>();
private final Map<String, Integer> bookmarks = new HashMap<String, Integer>();
private final static Logger logger = Logger.getLogger("Minecraft");
public HelpInput(final IUser user, final String match, final IEssentials ess) throws IOException
{
this.ess = ess;
final ISettings settings = ess.getSettings();
boolean reported = false;
final List<String> newLines = new ArrayList<String>();
@@ -147,7 +148,7 @@ public class HelpInput implements IText
{
if (!reported)
{
logger.log(Level.WARNING, _("Error getting help for plugin: {0}", pluginNameLow), ex);
ess.getLogger().log(Level.WARNING, _("Error getting help for plugin: {0}", pluginNameLow), ex);
}
reported = true;
continue;