Cleaned up logging.

This commit is contained in:
FrozenCow 2011-05-18 14:17:58 +02:00
parent e28ee185b6
commit 7937a64f06
17 changed files with 54 additions and 103 deletions

View file

@ -9,14 +9,11 @@ import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Timer;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.Location;
import org.bukkit.World;
@ -51,9 +48,6 @@ import org.dynmap.web.handlers.FilesystemHandler;
import org.dynmap.web.handlers.SendMessageHandler;
public class DynmapPlugin extends JavaPlugin {
protected static final Logger log = Logger.getLogger("Minecraft");
protected static final String LOG_PREFIX = "[dynmap] ";
public HttpServer webServer = null;
public MapManager mapManager = null;
public PlayerList playerList;
@ -90,7 +84,7 @@ public class DynmapPlugin extends JavaPlugin {
tilesDirectory = getFile(configuration.getString("tilespath", "web/tiles"));
if (!tilesDirectory.isDirectory() && !tilesDirectory.mkdirs()) {
log.warning(LOG_PREFIX + "Could not create directory for tiles ('" + tilesDirectory + "').");
Log.warning("Could not create directory for tiles ('" + tilesDirectory + "').");
}
playerList = new PlayerList(getServer(), getFile("hiddenplayers.txt"), configuration);
@ -125,7 +119,7 @@ public class DynmapPlugin extends JavaPlugin {
/* Print version info */
PluginDescriptionFile pdfFile = this.getDescription();
log.info(LOG_PREFIX + "version " + pdfFile.getVersion() + " is enabled" );
Log.info("version " + pdfFile.getVersion() + " is enabled" );
}
public void loadWebserver() {
@ -166,7 +160,7 @@ public class DynmapPlugin extends JavaPlugin {
try {
webServer.startServer();
} catch (IOException e) {
log.severe(LOG_PREFIX + "Failed to start WebServer on " + bindAddress + ":" + port + "!");
Log.severe("Failed to start WebServer on " + bindAddress + ":" + port + "!");
}
}
@ -295,7 +289,7 @@ public class DynmapPlugin extends JavaPlugin {
Debugger debugger = (Debugger) constructor.newInstance(this, debuggerConfiguration);
Debug.addDebugger(debugger);
} catch (Exception e) {
log.severe(LOG_PREFIX + "Error loading debugger: " + e);
Log.severe("Error loading debugger: " + e);
e.printStackTrace();
continue;
}
@ -401,15 +395,15 @@ public class DynmapPlugin extends JavaPlugin {
fos.write(Json.stringifyJson(clientConfig).getBytes());
fos.close();
} catch (FileNotFoundException ex) {
log.log(Level.SEVERE, LOG_PREFIX + "Exception while writing JSON-configuration-file.", ex);
Log.severe("Exception while writing JSON-configuration-file.", ex);
} catch (IOException ioe) {
log.log(Level.SEVERE, LOG_PREFIX + "Exception while writing JSON-configuration-file.", ioe);
Log.severe("Exception while writing JSON-configuration-file.", ioe);
}
}
public void webChat(String name, String message) {
mapManager.pushUpdate(new Client.ChatMessage("web", name, message));
log.info(LOG_PREFIX + "[WEB]" + name + ": " + message);
Log.info("[WEB]" + name + ": " + message);
/* Let HeroChat take a look - only broadcast to players if it doesn't handle it */
if(hchand.sendWebMessageToHeroChat(name, message) == false)
getServer().broadcastMessage("[WEB]" + name + ": " + message);