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

@ -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;
}