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

@ -4,13 +4,8 @@ import java.util.HashSet;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
import java.util.Set; import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
public class AsynchronousQueue<T> { public class AsynchronousQueue<T> {
protected static final Logger log = Logger.getLogger("Minecraft");
protected static final String LOG_PREFIX = "[dynmap] ";
private Object lock = new Object(); private Object lock = new Object();
private Thread thread; private Thread thread;
private LinkedList<T> queue = new LinkedList<T>(); private LinkedList<T> queue = new LinkedList<T>();
@ -63,7 +58,7 @@ public class AsynchronousQueue<T> {
try { try {
thread.setPriority(Thread.MIN_PRIORITY); thread.setPriority(Thread.MIN_PRIORITY);
} catch (SecurityException e) { } 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<T> {
Thread oldThread = thread; Thread oldThread = thread;
thread = null; thread = null;
log.info(LOG_PREFIX + "Stopping map renderer..."); Log.info("Stopping map renderer...");
oldThread.interrupt(); oldThread.interrupt();
try { try {
oldThread.join(1000); oldThread.join(1000);
} catch (InterruptedException e) { } 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<T> {
} }
} catch (Exception ex) { } catch (Exception ex) {
log.log(Level.SEVERE, LOG_PREFIX + "Exception on rendering-thread", ex); Log.severe("Exception on rendering-thread", ex);
} }
} }

View File

@ -6,14 +6,10 @@ import java.io.FileNotFoundException;
import java.io.InputStream; import java.io.InputStream;
import java.util.HashMap; import java.util.HashMap;
import java.util.Scanner; import java.util.Scanner;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.dynmap.debug.Debug; import org.dynmap.debug.Debug;
public class ColorScheme { public class ColorScheme {
protected static final Logger log = Logger.getLogger("Minecraft");
protected static final String LOG_PREFIX = "[dynmap] ";
private static final HashMap<String, ColorScheme> cache = new HashMap<String, ColorScheme>(); private static final HashMap<String, ColorScheme> cache = new HashMap<String, ColorScheme>();
public String name; public String name;
@ -115,10 +111,10 @@ public class ColorScheme {
} }
} }
} catch (RuntimeException e) { } 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; return null;
} catch (FileNotFoundException e) { } 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); return new ColorScheme(name, colors, datacolors);
} }

View File

@ -7,7 +7,6 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.logging.Level;
public class ConfigurationNode implements Map<String, Object> { public class ConfigurationNode implements Map<String, Object> {
public Map<String, Object> entries; public Map<String, Object> entries;
@ -168,7 +167,7 @@ public class ConfigurationNode implements Map<String, Object> {
return t; return t;
} catch (Exception e) { } catch (Exception e) {
// TODO: Remove reference to MapManager. // 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(); e.printStackTrace();
} }
return null; return null;

View File

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

View File

@ -3,7 +3,6 @@ package org.dynmap;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.logging.Logger;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.event.CustomEventListener; import org.bukkit.event.CustomEventListener;
@ -13,9 +12,6 @@ import org.bukkit.event.server.ServerListener;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
public class HeroChatHandler { 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 String DEF_CHANNEL = "Global";
private static final List<String> DEF_CHANNELS = Collections private static final List<String> DEF_CHANNELS = Collections
.singletonList(DEF_CHANNEL); .singletonList(DEF_CHANNEL);
@ -156,7 +152,7 @@ public class HeroChatHandler {
isgood = true; isgood = true;
} catch (ClassNotFoundException cnfx) { } catch (ClassNotFoundException cnfx) {
} catch (NoSuchMethodException nsmx) { } catch (NoSuchMethodException nsmx) {
log.severe(LOG_PREFIX + nsmx); Log.severe(nsmx);
} }
return isgood; return isgood;
} }
@ -229,7 +225,7 @@ public class HeroChatHandler {
public HeroChatHandler(ConfigurationNode cfg, DynmapPlugin plugin, Server server) { public HeroChatHandler(ConfigurationNode cfg, DynmapPlugin plugin, Server server) {
/* If we're enabling hero chat support */ /* If we're enabling hero chat support */
if (cfg.getNode("web").getBoolean("enableherochat", false)) { if (cfg.getNode("web").getBoolean("enableherochat", false)) {
log.info(LOG_PREFIX + "HeroChat support configured"); Log.info("HeroChat support configured");
this.plugin = plugin; this.plugin = plugin;
/* Now, get the monitored channel list */ /* Now, get the monitored channel list */
hcchannels = cfg.getStrings("web/herochatchannels", hcchannels = cfg.getStrings("web/herochatchannels",
@ -245,22 +241,22 @@ public class HeroChatHandler {
private void activateHeroChat(Plugin herochat) { private void activateHeroChat(Plugin herochat) {
if (HeroChatChannelChatEvent.initialize() == false) { if (HeroChatChannelChatEvent.initialize() == false) {
log.severe(LOG_PREFIX + "Cannot load HeroChat chat event class!"); Log.severe("Cannot load HeroChat chat event class!");
return; return;
} }
if (HeroChatChannel.initialize() == false) { if (HeroChatChannel.initialize() == false) {
log.severe(LOG_PREFIX + "Cannot load HeroChat channel class!"); Log.severe("Cannot load HeroChat channel class!");
return; return;
} }
if (HeroChatChannelEvent.initialize() == false) { if (HeroChatChannelEvent.initialize() == false) {
log.severe(LOG_PREFIX + "Cannot load HeroChat channel event class!"); Log.severe("Cannot load HeroChat channel event class!");
return; return;
} }
/* Register event handler */ /* Register event handler */
plugin.getServer().getPluginManager().registerEvent(Event.Type.CUSTOM_EVENT, plugin.getServer().getPluginManager().registerEvent(Event.Type.CUSTOM_EVENT,
new OurEventListener(), Event.Priority.Monitor, plugin); 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 * Send message from web to appropriate HeroChat channel

View File

@ -8,8 +8,6 @@ import java.io.IOException;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map; import java.util.Map;
import java.util.TimerTask; import java.util.TimerTask;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Server; import org.bukkit.Server;
@ -22,9 +20,6 @@ import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException; import org.json.simple.parser.ParseException;
class JsonTimerTask extends TimerTask { class JsonTimerTask extends TimerTask {
protected static final Logger log = Logger.getLogger("Minecraft");
protected static final String LOG_PREFIX = "[dynmap] ";
private final DynmapPlugin plugin; private final DynmapPlugin plugin;
private Server server; private Server server;
private MapManager mapManager; private MapManager mapManager;
@ -65,9 +60,9 @@ class JsonTimerTask extends TimerTask {
jsonMsgs = (JSONArray) parser.parse(inputFileReader); jsonMsgs = (JSONArray) parser.parse(inputFileReader);
inputFileReader.close(); inputFileReader.close();
} catch (IOException ex) { } 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) { } 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) { if (jsonMsgs != null) {
@ -119,9 +114,9 @@ class JsonTimerTask extends TimerTask {
fos.write(Json.stringifyJson(update).getBytes()); fos.write(Json.stringifyJson(update).getBytes());
fos.close(); fos.close();
} catch (FileNotFoundException ex) { } 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) { } 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(); lastTimestamp = System.currentTimeMillis();
@ -165,9 +160,9 @@ class JsonTimerTask extends TimerTask {
fos.write(Json.stringifyJson(regionData).getBytes()); fos.write(Json.stringifyJson(regionData).getBytes());
fos.close(); fos.close();
} catch (FileNotFoundException ex) { } 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) { } catch (IOException ioe) {
log.log(Level.SEVERE, LOG_PREFIX + "Exception while writing JSON-file.", ioe); Log.severe("Exception while writing JSON-file.", ioe);
} }
} }
} }

View File

@ -1,15 +1,10 @@
package org.dynmap; package org.dynmap;
import java.io.File; import java.io.File;
import java.lang.reflect.Constructor;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.Chunk; import org.bukkit.Chunk;
import org.bukkit.Location; import org.bukkit.Location;
@ -19,9 +14,6 @@ import org.bukkit.scheduler.BukkitScheduler;
import org.dynmap.debug.Debug; import org.dynmap.debug.Debug;
public class MapManager { public class MapManager {
protected static final Logger log = Logger.getLogger("Minecraft");
protected static final String LOG_PREFIX = "[dynmap] ";
public AsynchronousQueue<MapTile> tileQueue; public AsynchronousQueue<MapTile> tileQueue;
public AsynchronousQueue<ImageWriter> writeQueue; public AsynchronousQueue<ImageWriter> writeQueue;
@ -85,7 +77,7 @@ public class MapManager {
rendercnt = 0; rendercnt = 0;
map_index++; /* Next map */ map_index++; /* Next map */
if(map_index >= world.maps.size()) { /* Last one done? */ 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()); active_renders.remove(world.world.getName());
return; 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.<MapType>createInstances("maps", new Class<?>[0], new Object[0])) { for(MapType map : worldConfiguration.<MapType>createInstances("maps", new Class<?>[0], new Object[0])) {
map.onTileInvalidated.addListener(invalitateListener); map.onTileInvalidated.addListener(invalitateListener);
world.maps.add(map); 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); inactiveworlds.put(worldName, world);
@ -224,27 +216,27 @@ public class MapManager {
void renderFullWorld(Location l) { void renderFullWorld(Location l) {
DynmapWorld world = worlds.get(l.getWorld().getName()); DynmapWorld world = worlds.get(l.getWorld().getName());
if (world == null) { 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; return;
} }
if(do_timesliced_render) { if(do_timesliced_render) {
String wname = l.getWorld().getName(); String wname = l.getWorld().getName();
FullWorldRenderState rndr = active_renders.get(wname); FullWorldRenderState rndr = active_renders.get(wname);
if(rndr != null) { 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; return;
} }
rndr = new FullWorldRenderState(world,l); /* Make new activation record */ rndr = new FullWorldRenderState(world,l); /* Make new activation record */
active_renders.put(wname, rndr); /* Add to active table */ active_renders.put(wname, rndr); /* Add to active table */
/* Schedule first tile to be worked */ /* Schedule first tile to be worked */
scheduler.scheduleSyncDelayedTask(plug_in, rndr, (int)(timeslice_interval*20)); 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; return;
} }
World w = world.world; 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) { for (MapType map : world.maps) {
int requiredChunkCount = 200; int requiredChunkCount = 200;
HashSet<MapTile> found = new HashSet<MapTile>(); HashSet<MapTile> found = new HashSet<MapTile>();
@ -298,7 +290,7 @@ public class MapManager {
w.unloadChunk(c.x, c.z, false, true); 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) { public void activateWorld(World w) {
@ -311,7 +303,7 @@ public class MapManager {
if (world != null) { if (world != null) {
world.world = w; world.world = w;
worlds.put(w.getName(), world); 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); worldTileDirectories.put(world, worldTileDirectory);
} }
if (!worldTileDirectory.isDirectory() && !worldTileDirectory.mkdirs()) { 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()); return new File(worldTileDirectory, tile.getFilename());
} }

View File

@ -1,32 +1,26 @@
package org.dynmap.debug; 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.bukkit.plugin.java.JavaPlugin;
import org.dynmap.ConfigurationNode; import org.dynmap.ConfigurationNode;
import org.dynmap.Log;
public class LogDebugger implements Debugger { 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) { public LogDebugger(JavaPlugin plugin, ConfigurationNode configuration) {
} }
@Override @Override
public void debug(String message) { public void debug(String message) {
log.info(LOG_PREFIX + message); Log.info(message);
} }
@Override @Override
public void error(String message) { public void error(String message) {
log.log(Level.SEVERE, LOG_PREFIX + message); Log.severe(message);
} }
@Override @Override
public void error(String message, Throwable thrown) { public void error(String message, Throwable thrown) {
log.log(Level.SEVERE, LOG_PREFIX + message); Log.severe(message);
thrown.printStackTrace(); thrown.printStackTrace();
} }

View File

@ -1,7 +1,5 @@
package org.dynmap.debug; package org.dynmap.debug;
import java.util.Map;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.dynmap.ConfigurationNode; import org.dynmap.ConfigurationNode;

View File

@ -4,7 +4,6 @@ import java.awt.image.BufferedImage;
import java.awt.image.WritableRaster; import java.awt.image.WritableRaster;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.Map;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;

View File

@ -1,7 +1,5 @@
package org.dynmap.kzedmap; package org.dynmap.kzedmap;
import java.util.Map;
import org.bukkit.World; import org.bukkit.World;
import org.dynmap.Color; import org.dynmap.Color;
import org.dynmap.ConfigurationNode; import org.dynmap.ConfigurationNode;

View File

@ -7,7 +7,6 @@ import java.awt.image.WritableRaster;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.HashSet; import java.util.HashSet;
import java.util.Map;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;

View File

@ -2,7 +2,6 @@ package org.dynmap.kzedmap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map;
import org.bukkit.World; import org.bukkit.World;
import org.dynmap.Color; import org.dynmap.Color;

View File

@ -1,20 +1,17 @@
package org.dynmap.kzedmap; package org.dynmap.kzedmap;
import java.io.File; import java.io.File;
import java.lang.reflect.Constructor;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
import org.dynmap.ConfigurationNode; import org.dynmap.ConfigurationNode;
import org.dynmap.DynmapChunk; import org.dynmap.DynmapChunk;
import org.dynmap.MapManager; import org.dynmap.Log;
import org.dynmap.MapTile; import org.dynmap.MapTile;
import org.dynmap.MapType; import org.dynmap.MapType;
import org.dynmap.debug.Debug;
public class KzedMap extends MapType { public class KzedMap extends MapType {
protected static final Logger log = Logger.getLogger("Minecraft"); protected static final Logger log = Logger.getLogger("Minecraft");
@ -40,11 +37,11 @@ public class KzedMap extends MapType {
ZoomedTileRenderer zoomrenderer; ZoomedTileRenderer zoomrenderer;
public KzedMap(ConfigurationNode configuration) { public KzedMap(ConfigurationNode configuration) {
log.info(LOG_PREFIX + "Loading renderers for map '" + getClass().toString() + "'..."); Log.info("Loading renderers for map '" + getClass().toString() + "'...");
List<MapTileRenderer> renderers = configuration.<MapTileRenderer>createInstances("renderers", new Class<?>[0], new Object[0]); List<MapTileRenderer> renderers = configuration.<MapTileRenderer>createInstances("renderers", new Class<?>[0], new Object[0]);
this.renderers = new MapTileRenderer[renderers.size()]; this.renderers = new MapTileRenderer[renderers.size()];
renderers.toArray(this.renderers); 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); zoomrenderer = new ZoomedTileRenderer(configuration);
} }

View File

@ -7,9 +7,10 @@ import java.net.Socket;
import java.util.Collections; import java.util.Collections;
import java.util.SortedMap; import java.util.SortedMap;
import java.util.TreeMap; import java.util.TreeMap;
import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.dynmap.Log;
public class HttpServer extends Thread { public class HttpServer extends Thread {
protected static final Logger log = Logger.getLogger("Minecraft"); protected static final Logger log = Logger.getLogger("Minecraft");
protected static final String LOG_PREFIX = "[dynmap] "; protected static final String LOG_PREFIX = "[dynmap] ";
@ -31,7 +32,7 @@ public class HttpServer extends Thread {
sock = new ServerSocket(port, 5, bindAddress); sock = new ServerSocket(port, 5, bindAddress);
listeningThread = this; listeningThread = this;
start(); start();
log.info(LOG_PREFIX + "Dynmap WebServer started on " + bindAddress + ":" + port); Log.info("Dynmap WebServer started on " + bindAddress + ":" + port);
} }
public void run() { public void run() {
@ -42,24 +43,24 @@ public class HttpServer extends Thread {
HttpServerConnection requestThread = new HttpServerConnection(socket, this); HttpServerConnection requestThread = new HttpServerConnection(socket, this);
requestThread.start(); requestThread.start();
} catch (IOException e) { } catch (IOException e) {
log.info(LOG_PREFIX + "map WebServer.run() stops with IOException"); Log.info("map WebServer.run() stops with IOException");
break; break;
} }
} }
log.info(LOG_PREFIX + "Webserver shut down."); Log.info("Webserver shut down.");
} catch (Exception ex) { } catch (Exception ex) {
log.log(Level.SEVERE, LOG_PREFIX + "Exception on WebServer-thread", ex); Log.severe("Exception on WebServer-thread", ex);
} }
} }
public void shutdown() { public void shutdown() {
log.info(LOG_PREFIX + "Shutting down webserver..."); Log.info("Shutting down webserver...");
try { try {
if (sock != null) { if (sock != null) {
sock.close(); sock.close();
} }
} catch (IOException e) { } 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; listeningThread = null;
} }

View File

@ -9,11 +9,11 @@ import java.io.StringWriter;
import java.net.Socket; import java.net.Socket;
import java.net.URLDecoder; import java.net.URLDecoder;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import org.dynmap.Log;
import org.dynmap.debug.Debug; import org.dynmap.debug.Debug;
public class HttpServerConnection extends Thread { public class HttpServerConnection extends Thread {
@ -175,7 +175,7 @@ public class HttpServerConnection extends Thread {
} catch (IOException e) { } catch (IOException e) {
throw e; throw e;
} catch (Exception 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) { if (socket != null) {
out.flush(); out.flush();
socket.close(); socket.close();
@ -229,7 +229,7 @@ public class HttpServerConnection extends Thread {
} catch (IOException ex) { } catch (IOException ex) {
} }
} }
log.log(Level.SEVERE, LOG_PREFIX + "Exception while handling request: ", e); Log.severe("Exception while handling request: ", e);
e.printStackTrace(); e.printStackTrace();
return; return;
} }

View File

@ -3,7 +3,6 @@ package org.dynmap.web;
import java.lang.reflect.Array; import java.lang.reflect.Array;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;