More logger tweaks.

This commit is contained in:
Steven Lawson 2013-08-20 20:04:06 -04:00
parent 75ec2330f5
commit 485945047b
4 changed files with 41 additions and 44 deletions

View File

@ -1,5 +1,5 @@
#Tue, 20 Aug 2013 17:31:27 +0200
#Tue, 20 Aug 2013 20:00:13 -0400
program.VERSION=3.1
program.BUILDNUM=469
program.BUILDDATE=08/20/2013 05\:31 PM
program.BUILDNUM=470
program.BUILDDATE=08/20/2013 08\:00 PM

View File

@ -1,3 +1,3 @@
#Build Number for ANT. Do not edit!
#Tue Aug 20 17:31:27 CEST 2013
build.number=470
#Tue Aug 20 20:00:13 EDT 2013
build.number=471

View File

@ -1,56 +1,59 @@
package me.StevenLawson.TotalFreedomMod;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.commons.lang.exception.ExceptionUtils;
import org.bukkit.Bukkit;
public class TFM_Log
{
private static final Logger logger = Bukkit.getLogger();
private static final Logger LOGGER = Bukkit.getLogger();
private TFM_Log()
{
throw new AssertionError();
}
public static void info(String message)
public static void info(Object... params)
{
TotalFreedomMod.logger.info(message);
prepareLogMessage(Level.INFO, params);
}
public static void info(String message, boolean raw)
public static void warning(Object... params)
{
if (raw)
prepareLogMessage(Level.WARNING, params);
}
public static void severe(Object... params)
{
prepareLogMessage(Level.SEVERE, params);
}
private static void prepareLogMessage(Level level, Object... params)
{
if (params.length == 0)
{
TotalFreedomMod.logger.info(message);
return;
}
Object payload = params[0];
if (payload instanceof Throwable)
{
log(level, (Throwable) payload);
}
else
{
info(message);
log(level, payload.toString(), params.length >= 2 && params[1] instanceof Boolean ? (Boolean) params[1] : false);
}
}
public static void severe(Object message)
private static void log(Level level, String message, boolean raw)
{
if (message instanceof Throwable)
{
TotalFreedomMod.logger.severe(ExceptionUtils.getFullStackTrace((Throwable) message));
}
else
{
TotalFreedomMod.logger.severe(String.valueOf(message));
}
LOGGER.log(level, (raw ? "" : "[" + TotalFreedomMod.pluginName + "]: ") + message);
}
public static void warning(Object message)
private static void log(Level level, Throwable throwable)
{
if (message instanceof Throwable)
{
TotalFreedomMod.logger.warning(ExceptionUtils.getFullStackTrace((Throwable) message));
}
else
{
TotalFreedomMod.logger.warning(String.valueOf(message));
}
LOGGER.log(level, null, throwable);
}
}

View File

@ -48,8 +48,6 @@ public class TotalFreedomMod extends JavaPlugin
public static TotalFreedomMod plugin = null;
public static File plugin_file = null;
//
public static Logger logger;
//
public static String pluginName = "";
public static String pluginVersion = "";
public static String buildNumber = "";
@ -69,14 +67,10 @@ public class TotalFreedomMod extends JavaPlugin
{
TotalFreedomMod.plugin = this;
TotalFreedomMod.plugin_file = plugin.getFile();
TotalFreedomMod.logger = plugin.getLogger();
TotalFreedomMod.pluginName = plugin.getDescription().getName();
setAppProperties();
logger = plugin.getLogger();
TFM_Log.info("Version: " + TotalFreedomMod.pluginVersion + "." + TotalFreedomMod.buildNumber + " by Madgeek1450 and DarthSalamon");
loadSuperadminConfig();
@ -162,16 +156,16 @@ public class TotalFreedomMod extends JavaPlugin
TFM_CommandBlocker.getInstance().parseBlockingRules();
}
}.runTaskLater(plugin, 20L);
TFM_Log.info("Plugin enabled");
TFM_Log.info("Plugin enabled.");
}
@Override
public void onDisable()
{
server.getScheduler().cancelTasks(plugin);
TFM_Log.info("Plugin disabled");
TFM_Log.info("Plugin disabled.");
}
@Override