From 7937a64f06099276685e4cd4382edcadb77463fb Mon Sep 17 00:00:00 2001 From: FrozenCow Date: Wed, 18 May 2011 14:17:58 +0200 Subject: [PATCH] Cleaned up logging. --- .../java/org/dynmap/AsynchronousQueue.java | 13 +++------ src/main/java/org/dynmap/ColorScheme.java | 8 ++---- .../java/org/dynmap/ConfigurationNode.java | 3 +- src/main/java/org/dynmap/DynmapPlugin.java | 20 +++++-------- src/main/java/org/dynmap/HeroChatHandler.java | 16 ++++------- src/main/java/org/dynmap/JsonTimerTask.java | 17 ++++------- src/main/java/org/dynmap/MapManager.java | 28 +++++++------------ .../java/org/dynmap/debug/LogDebugger.java | 14 +++------- .../java/org/dynmap/debug/NullDebugger.java | 2 -- src/main/java/org/dynmap/flat/FlatMap.java | 1 - .../org/dynmap/kzedmap/CaveTileRenderer.java | 2 -- .../dynmap/kzedmap/DefaultTileRenderer.java | 1 - .../dynmap/kzedmap/HighlightTileRenderer.java | 1 - src/main/java/org/dynmap/kzedmap/KzedMap.java | 9 ++---- src/main/java/org/dynmap/web/HttpServer.java | 15 +++++----- .../org/dynmap/web/HttpServerConnection.java | 6 ++-- src/main/java/org/dynmap/web/Json.java | 1 - 17 files changed, 54 insertions(+), 103 deletions(-) diff --git a/src/main/java/org/dynmap/AsynchronousQueue.java b/src/main/java/org/dynmap/AsynchronousQueue.java index 828ceffb..8b9a854e 100644 --- a/src/main/java/org/dynmap/AsynchronousQueue.java +++ b/src/main/java/org/dynmap/AsynchronousQueue.java @@ -4,13 +4,8 @@ import java.util.HashSet; import java.util.LinkedList; import java.util.NoSuchElementException; import java.util.Set; -import java.util.logging.Level; -import java.util.logging.Logger; public class AsynchronousQueue { - protected static final Logger log = Logger.getLogger("Minecraft"); - protected static final String LOG_PREFIX = "[dynmap] "; - private Object lock = new Object(); private Thread thread; private LinkedList queue = new LinkedList(); @@ -63,7 +58,7 @@ public class AsynchronousQueue { try { thread.setPriority(Thread.MIN_PRIORITY); } catch (SecurityException e) { - log.info(LOG_PREFIX + "Failed to set minimum priority for worker thread!"); + Log.info("Failed to set minimum priority for worker thread!"); } } } @@ -75,13 +70,13 @@ public class AsynchronousQueue { Thread oldThread = thread; thread = null; - log.info(LOG_PREFIX + "Stopping map renderer..."); + Log.info("Stopping map renderer..."); oldThread.interrupt(); try { oldThread.join(1000); } catch (InterruptedException e) { - log.info(LOG_PREFIX + "Waiting for map renderer to stop is interrupted"); + Log.info("Waiting for map renderer to stop is interrupted"); } } } @@ -97,7 +92,7 @@ public class AsynchronousQueue { } } catch (Exception ex) { - log.log(Level.SEVERE, LOG_PREFIX + "Exception on rendering-thread", ex); + Log.severe("Exception on rendering-thread", ex); } } diff --git a/src/main/java/org/dynmap/ColorScheme.java b/src/main/java/org/dynmap/ColorScheme.java index dc32a1ae..37b77d03 100644 --- a/src/main/java/org/dynmap/ColorScheme.java +++ b/src/main/java/org/dynmap/ColorScheme.java @@ -6,14 +6,10 @@ import java.io.FileNotFoundException; import java.io.InputStream; import java.util.HashMap; import java.util.Scanner; -import java.util.logging.Level; -import java.util.logging.Logger; import org.dynmap.debug.Debug; public class ColorScheme { - protected static final Logger log = Logger.getLogger("Minecraft"); - protected static final String LOG_PREFIX = "[dynmap] "; private static final HashMap cache = new HashMap(); public String name; @@ -115,10 +111,10 @@ public class ColorScheme { } } } catch (RuntimeException e) { - log.log(Level.SEVERE, LOG_PREFIX + "Could not load colors '" + name + "' ('" + colorSchemeFile + "').", e); + Log.severe("Could not load colors '" + name + "' ('" + colorSchemeFile + "').", e); return null; } catch (FileNotFoundException e) { - log.log(Level.SEVERE, LOG_PREFIX + "Could not load colors '" + name + "' ('" + colorSchemeFile + "'): File not found.", e); + Log.severe("Could not load colors '" + name + "' ('" + colorSchemeFile + "'): File not found.", e); } return new ColorScheme(name, colors, datacolors); } diff --git a/src/main/java/org/dynmap/ConfigurationNode.java b/src/main/java/org/dynmap/ConfigurationNode.java index 5fcd086b..139924f7 100644 --- a/src/main/java/org/dynmap/ConfigurationNode.java +++ b/src/main/java/org/dynmap/ConfigurationNode.java @@ -7,7 +7,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.logging.Level; public class ConfigurationNode implements Map { public Map entries; @@ -168,7 +167,7 @@ public class ConfigurationNode implements Map { return t; } catch (Exception e) { // TODO: Remove reference to MapManager. - MapManager.log.log(Level.SEVERE, MapManager.LOG_PREFIX + "Error loading maptype", e); + Log.severe("Error loading maptype", e); e.printStackTrace(); } return null; diff --git a/src/main/java/org/dynmap/DynmapPlugin.java b/src/main/java/org/dynmap/DynmapPlugin.java index e8710411..16298564 100644 --- a/src/main/java/org/dynmap/DynmapPlugin.java +++ b/src/main/java/org/dynmap/DynmapPlugin.java @@ -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); diff --git a/src/main/java/org/dynmap/HeroChatHandler.java b/src/main/java/org/dynmap/HeroChatHandler.java index cc0aeffa..bd42cc85 100644 --- a/src/main/java/org/dynmap/HeroChatHandler.java +++ b/src/main/java/org/dynmap/HeroChatHandler.java @@ -3,7 +3,6 @@ package org.dynmap; import java.lang.reflect.Method; import java.util.Collections; import java.util.List; -import java.util.logging.Logger; import org.bukkit.Server; import org.bukkit.event.CustomEventListener; @@ -13,9 +12,6 @@ import org.bukkit.event.server.ServerListener; import org.bukkit.plugin.Plugin; public class HeroChatHandler { - protected static final Logger log = Logger.getLogger("Minecraft"); - protected static final String LOG_PREFIX = "[dynmap] "; - private static final String DEF_CHANNEL = "Global"; private static final List DEF_CHANNELS = Collections .singletonList(DEF_CHANNEL); @@ -156,7 +152,7 @@ public class HeroChatHandler { isgood = true; } catch (ClassNotFoundException cnfx) { } catch (NoSuchMethodException nsmx) { - log.severe(LOG_PREFIX + nsmx); + Log.severe(nsmx); } return isgood; } @@ -229,7 +225,7 @@ public class HeroChatHandler { public HeroChatHandler(ConfigurationNode cfg, DynmapPlugin plugin, Server server) { /* If we're enabling hero chat support */ if (cfg.getNode("web").getBoolean("enableherochat", false)) { - log.info(LOG_PREFIX + "HeroChat support configured"); + Log.info("HeroChat support configured"); this.plugin = plugin; /* Now, get the monitored channel list */ hcchannels = cfg.getStrings("web/herochatchannels", @@ -245,22 +241,22 @@ public class HeroChatHandler { private void activateHeroChat(Plugin herochat) { if (HeroChatChannelChatEvent.initialize() == false) { - log.severe(LOG_PREFIX + "Cannot load HeroChat chat event class!"); + Log.severe("Cannot load HeroChat chat event class!"); return; } if (HeroChatChannel.initialize() == false) { - log.severe(LOG_PREFIX + "Cannot load HeroChat channel class!"); + Log.severe("Cannot load HeroChat channel class!"); return; } if (HeroChatChannelEvent.initialize() == false) { - log.severe(LOG_PREFIX + "Cannot load HeroChat channel event class!"); + Log.severe("Cannot load HeroChat channel event class!"); return; } /* Register event handler */ plugin.getServer().getPluginManager().registerEvent(Event.Type.CUSTOM_EVENT, new OurEventListener(), Event.Priority.Monitor, plugin); - log.info(LOG_PREFIX + "HeroChat integration active"); + Log.info("HeroChat integration active"); } /** * Send message from web to appropriate HeroChat channel diff --git a/src/main/java/org/dynmap/JsonTimerTask.java b/src/main/java/org/dynmap/JsonTimerTask.java index 2666ca1b..71390526 100644 --- a/src/main/java/org/dynmap/JsonTimerTask.java +++ b/src/main/java/org/dynmap/JsonTimerTask.java @@ -8,8 +8,6 @@ import java.io.IOException; import java.util.Iterator; import java.util.Map; import java.util.TimerTask; -import java.util.logging.Level; -import java.util.logging.Logger; import org.bukkit.Location; import org.bukkit.Server; @@ -22,9 +20,6 @@ import org.json.simple.parser.JSONParser; import org.json.simple.parser.ParseException; class JsonTimerTask extends TimerTask { - protected static final Logger log = Logger.getLogger("Minecraft"); - protected static final String LOG_PREFIX = "[dynmap] "; - private final DynmapPlugin plugin; private Server server; private MapManager mapManager; @@ -65,9 +60,9 @@ class JsonTimerTask extends TimerTask { jsonMsgs = (JSONArray) parser.parse(inputFileReader); inputFileReader.close(); } catch (IOException ex) { - log.log(Level.SEVERE, LOG_PREFIX + "Exception while reading JSON-file.", ex); + Log.severe("Exception while reading JSON-file.", ex); } catch (ParseException ex) { - log.log(Level.SEVERE, LOG_PREFIX + "Exception while parsing JSON-file.", ex); + Log.severe("Exception while parsing JSON-file.", ex); } if (jsonMsgs != null) { @@ -119,9 +114,9 @@ class JsonTimerTask extends TimerTask { fos.write(Json.stringifyJson(update).getBytes()); fos.close(); } catch (FileNotFoundException ex) { - log.log(Level.SEVERE, LOG_PREFIX + "Exception while writing JSON-file.", ex); + Log.severe("Exception while writing JSON-file.", ex); } catch (IOException ioe) { - log.log(Level.SEVERE, LOG_PREFIX + "Exception while writing JSON-file.", ioe); + Log.severe("Exception while writing JSON-file.", ioe); } } lastTimestamp = System.currentTimeMillis(); @@ -165,9 +160,9 @@ class JsonTimerTask extends TimerTask { fos.write(Json.stringifyJson(regionData).getBytes()); fos.close(); } catch (FileNotFoundException ex) { - log.log(Level.SEVERE, LOG_PREFIX + "Exception while writing JSON-file.", ex); + Log.severe("Exception while writing JSON-file.", ex); } catch (IOException ioe) { - log.log(Level.SEVERE, LOG_PREFIX + "Exception while writing JSON-file.", ioe); + Log.severe("Exception while writing JSON-file.", ioe); } } } diff --git a/src/main/java/org/dynmap/MapManager.java b/src/main/java/org/dynmap/MapManager.java index e2395292..413dbbc3 100644 --- a/src/main/java/org/dynmap/MapManager.java +++ b/src/main/java/org/dynmap/MapManager.java @@ -1,15 +1,10 @@ package org.dynmap; import java.io.File; -import java.lang.reflect.Constructor; -import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedList; -import java.util.List; import java.util.Map; -import java.util.logging.Level; -import java.util.logging.Logger; import org.bukkit.Chunk; import org.bukkit.Location; @@ -19,9 +14,6 @@ import org.bukkit.scheduler.BukkitScheduler; import org.dynmap.debug.Debug; public class MapManager { - protected static final Logger log = Logger.getLogger("Minecraft"); - protected static final String LOG_PREFIX = "[dynmap] "; - public AsynchronousQueue tileQueue; public AsynchronousQueue writeQueue; @@ -85,7 +77,7 @@ public class MapManager { rendercnt = 0; map_index++; /* Next map */ if(map_index >= world.maps.size()) { /* Last one done? */ - log.info(LOG_PREFIX + "Full render finished."); + Log.info("Full render finished."); active_renders.remove(world.world.getName()); return; } @@ -198,12 +190,12 @@ public class MapManager { } }; - log.info(LOG_PREFIX + "Loading maps of world '" + worldName + "'..."); + Log.info("Loading maps of world '" + worldName + "'..."); for(MapType map : worldConfiguration.createInstances("maps", new Class[0], new Object[0])) { map.onTileInvalidated.addListener(invalitateListener); world.maps.add(map); } - log.info(LOG_PREFIX + "Loaded " + world.maps.size() + " maps of world '" + worldName + "'."); + Log.info("Loaded " + world.maps.size() + " maps of world '" + worldName + "'."); inactiveworlds.put(worldName, world); @@ -224,27 +216,27 @@ public class MapManager { void renderFullWorld(Location l) { DynmapWorld world = worlds.get(l.getWorld().getName()); if (world == null) { - log.severe(LOG_PREFIX + "Could not render: world '" + l.getWorld().getName() + "' not defined in configuration."); + Log.severe("Could not render: world '" + l.getWorld().getName() + "' not defined in configuration."); return; } if(do_timesliced_render) { String wname = l.getWorld().getName(); FullWorldRenderState rndr = active_renders.get(wname); if(rndr != null) { - log.info(LOG_PREFIX + "Full world render of world '" + wname + "' already active."); + Log.info("Full world render of world '" + wname + "' already active."); return; } rndr = new FullWorldRenderState(world,l); /* Make new activation record */ active_renders.put(wname, rndr); /* Add to active table */ /* Schedule first tile to be worked */ scheduler.scheduleSyncDelayedTask(plug_in, rndr, (int)(timeslice_interval*20)); - log.info(LOG_PREFIX + "Full render starting on world '" + wname + "' (timesliced)..."); + Log.info("Full render starting on world '" + wname + "' (timesliced)..."); return; } World w = world.world; - log.info(LOG_PREFIX + "Full render starting on world '" + w.getName() + "'..."); + Log.info("Full render starting on world '" + w.getName() + "'..."); for (MapType map : world.maps) { int requiredChunkCount = 200; HashSet found = new HashSet(); @@ -298,7 +290,7 @@ public class MapManager { w.unloadChunk(c.x, c.z, false, true); } } - log.info(LOG_PREFIX + "Full render finished."); + Log.info("Full render finished."); } public void activateWorld(World w) { @@ -311,7 +303,7 @@ public class MapManager { if (world != null) { world.world = w; worlds.put(w.getName(), world); - log.info(LOG_PREFIX + "Activated world '" + w.getName() + "' in Dynmap."); + Log.info("Activated world '" + w.getName() + "' in Dynmap."); } } @@ -361,7 +353,7 @@ public class MapManager { worldTileDirectories.put(world, worldTileDirectory); } if (!worldTileDirectory.isDirectory() && !worldTileDirectory.mkdirs()) { - log.warning(LOG_PREFIX + "Could not create directory for tiles ('" + worldTileDirectory + "')."); + Log.warning("Could not create directory for tiles ('" + worldTileDirectory + "')."); } return new File(worldTileDirectory, tile.getFilename()); } diff --git a/src/main/java/org/dynmap/debug/LogDebugger.java b/src/main/java/org/dynmap/debug/LogDebugger.java index 2ac8d025..41e43131 100644 --- a/src/main/java/org/dynmap/debug/LogDebugger.java +++ b/src/main/java/org/dynmap/debug/LogDebugger.java @@ -1,32 +1,26 @@ package org.dynmap.debug; -import java.util.Map; -import java.util.logging.Level; -import java.util.logging.Logger; - import org.bukkit.plugin.java.JavaPlugin; import org.dynmap.ConfigurationNode; +import org.dynmap.Log; public class LogDebugger implements Debugger { - protected static final Logger log = Logger.getLogger("Minecraft"); - protected static final String LOG_PREFIX = "[dynmap] "; - public LogDebugger(JavaPlugin plugin, ConfigurationNode configuration) { } @Override public void debug(String message) { - log.info(LOG_PREFIX + message); + Log.info(message); } @Override public void error(String message) { - log.log(Level.SEVERE, LOG_PREFIX + message); + Log.severe(message); } @Override public void error(String message, Throwable thrown) { - log.log(Level.SEVERE, LOG_PREFIX + message); + Log.severe(message); thrown.printStackTrace(); } diff --git a/src/main/java/org/dynmap/debug/NullDebugger.java b/src/main/java/org/dynmap/debug/NullDebugger.java index 485790c6..1e4c7aac 100644 --- a/src/main/java/org/dynmap/debug/NullDebugger.java +++ b/src/main/java/org/dynmap/debug/NullDebugger.java @@ -1,7 +1,5 @@ package org.dynmap.debug; -import java.util.Map; - import org.bukkit.plugin.java.JavaPlugin; import org.dynmap.ConfigurationNode; diff --git a/src/main/java/org/dynmap/flat/FlatMap.java b/src/main/java/org/dynmap/flat/FlatMap.java index 1aaef2d7..59f30ae2 100644 --- a/src/main/java/org/dynmap/flat/FlatMap.java +++ b/src/main/java/org/dynmap/flat/FlatMap.java @@ -4,7 +4,6 @@ import java.awt.image.BufferedImage; import java.awt.image.WritableRaster; import java.io.File; import java.io.IOException; -import java.util.Map; import javax.imageio.ImageIO; diff --git a/src/main/java/org/dynmap/kzedmap/CaveTileRenderer.java b/src/main/java/org/dynmap/kzedmap/CaveTileRenderer.java index 7d6d00dc..d07f5713 100644 --- a/src/main/java/org/dynmap/kzedmap/CaveTileRenderer.java +++ b/src/main/java/org/dynmap/kzedmap/CaveTileRenderer.java @@ -1,7 +1,5 @@ package org.dynmap.kzedmap; -import java.util.Map; - import org.bukkit.World; import org.dynmap.Color; import org.dynmap.ConfigurationNode; diff --git a/src/main/java/org/dynmap/kzedmap/DefaultTileRenderer.java b/src/main/java/org/dynmap/kzedmap/DefaultTileRenderer.java index 5a9896a0..963c5d39 100644 --- a/src/main/java/org/dynmap/kzedmap/DefaultTileRenderer.java +++ b/src/main/java/org/dynmap/kzedmap/DefaultTileRenderer.java @@ -7,7 +7,6 @@ import java.awt.image.WritableRaster; import java.io.File; import java.io.IOException; import java.util.HashSet; -import java.util.Map; import javax.imageio.ImageIO; diff --git a/src/main/java/org/dynmap/kzedmap/HighlightTileRenderer.java b/src/main/java/org/dynmap/kzedmap/HighlightTileRenderer.java index 0c3318d1..d5314e54 100644 --- a/src/main/java/org/dynmap/kzedmap/HighlightTileRenderer.java +++ b/src/main/java/org/dynmap/kzedmap/HighlightTileRenderer.java @@ -2,7 +2,6 @@ package org.dynmap.kzedmap; import java.util.HashSet; import java.util.List; -import java.util.Map; import org.bukkit.World; import org.dynmap.Color; diff --git a/src/main/java/org/dynmap/kzedmap/KzedMap.java b/src/main/java/org/dynmap/kzedmap/KzedMap.java index e42a34d7..ab395aa7 100644 --- a/src/main/java/org/dynmap/kzedmap/KzedMap.java +++ b/src/main/java/org/dynmap/kzedmap/KzedMap.java @@ -1,20 +1,17 @@ package org.dynmap.kzedmap; import java.io.File; -import java.lang.reflect.Constructor; import java.util.ArrayList; import java.util.List; -import java.util.Map; import java.util.logging.Logger; import org.bukkit.Location; import org.bukkit.World; import org.dynmap.ConfigurationNode; import org.dynmap.DynmapChunk; -import org.dynmap.MapManager; +import org.dynmap.Log; import org.dynmap.MapTile; import org.dynmap.MapType; -import org.dynmap.debug.Debug; public class KzedMap extends MapType { protected static final Logger log = Logger.getLogger("Minecraft"); @@ -40,11 +37,11 @@ public class KzedMap extends MapType { ZoomedTileRenderer zoomrenderer; public KzedMap(ConfigurationNode configuration) { - log.info(LOG_PREFIX + "Loading renderers for map '" + getClass().toString() + "'..."); + Log.info("Loading renderers for map '" + getClass().toString() + "'..."); List renderers = configuration.createInstances("renderers", new Class[0], new Object[0]); this.renderers = new MapTileRenderer[renderers.size()]; renderers.toArray(this.renderers); - log.info(LOG_PREFIX + "Loaded " + renderers.size() + " renderers for map '" + getClass().toString() + "'."); + Log.info("Loaded " + renderers.size() + " renderers for map '" + getClass().toString() + "'."); zoomrenderer = new ZoomedTileRenderer(configuration); } diff --git a/src/main/java/org/dynmap/web/HttpServer.java b/src/main/java/org/dynmap/web/HttpServer.java index 1a0bbb6f..8ba67232 100644 --- a/src/main/java/org/dynmap/web/HttpServer.java +++ b/src/main/java/org/dynmap/web/HttpServer.java @@ -7,9 +7,10 @@ import java.net.Socket; import java.util.Collections; import java.util.SortedMap; import java.util.TreeMap; -import java.util.logging.Level; import java.util.logging.Logger; +import org.dynmap.Log; + public class HttpServer extends Thread { protected static final Logger log = Logger.getLogger("Minecraft"); protected static final String LOG_PREFIX = "[dynmap] "; @@ -31,7 +32,7 @@ public class HttpServer extends Thread { sock = new ServerSocket(port, 5, bindAddress); listeningThread = this; start(); - log.info(LOG_PREFIX + "Dynmap WebServer started on " + bindAddress + ":" + port); + Log.info("Dynmap WebServer started on " + bindAddress + ":" + port); } public void run() { @@ -42,24 +43,24 @@ public class HttpServer extends Thread { HttpServerConnection requestThread = new HttpServerConnection(socket, this); requestThread.start(); } catch (IOException e) { - log.info(LOG_PREFIX + "map WebServer.run() stops with IOException"); + Log.info("map WebServer.run() stops with IOException"); break; } } - log.info(LOG_PREFIX + "Webserver shut down."); + Log.info("Webserver shut down."); } catch (Exception ex) { - log.log(Level.SEVERE, LOG_PREFIX + "Exception on WebServer-thread", ex); + Log.severe("Exception on WebServer-thread", ex); } } public void shutdown() { - log.info(LOG_PREFIX + "Shutting down webserver..."); + Log.info("Shutting down webserver..."); try { if (sock != null) { sock.close(); } } catch (IOException e) { - log.log(Level.INFO, LOG_PREFIX + "Exception while closing socket for webserver shutdown", e); + Log.warning("Exception while closing socket for webserver shutdown", e); } listeningThread = null; } diff --git a/src/main/java/org/dynmap/web/HttpServerConnection.java b/src/main/java/org/dynmap/web/HttpServerConnection.java index 0f7c8036..606eb3e3 100644 --- a/src/main/java/org/dynmap/web/HttpServerConnection.java +++ b/src/main/java/org/dynmap/web/HttpServerConnection.java @@ -9,11 +9,11 @@ import java.io.StringWriter; import java.net.Socket; import java.net.URLDecoder; import java.util.Map.Entry; -import java.util.logging.Level; import java.util.logging.Logger; import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.dynmap.Log; import org.dynmap.debug.Debug; public class HttpServerConnection extends Thread { @@ -175,7 +175,7 @@ public class HttpServerConnection extends Thread { } catch (IOException e) { throw e; } catch (Exception e) { - log.log(Level.SEVERE, LOG_PREFIX + "HttpHandler '" + handler + "' has thown an exception", e); + Log.severe("HttpHandler '" + handler + "' has thown an exception", e); if (socket != null) { out.flush(); socket.close(); @@ -229,7 +229,7 @@ public class HttpServerConnection extends Thread { } catch (IOException ex) { } } - log.log(Level.SEVERE, LOG_PREFIX + "Exception while handling request: ", e); + Log.severe("Exception while handling request: ", e); e.printStackTrace(); return; } diff --git a/src/main/java/org/dynmap/web/Json.java b/src/main/java/org/dynmap/web/Json.java index 05284cfd..6ad618b9 100644 --- a/src/main/java/org/dynmap/web/Json.java +++ b/src/main/java/org/dynmap/web/Json.java @@ -3,7 +3,6 @@ package org.dynmap.web; import java.lang.reflect.Array; import java.lang.reflect.Field; import java.lang.reflect.Modifier; -import java.util.LinkedHashMap; import java.util.List; import java.util.Map;