Prefix all (intentional) output properly.

This commit is contained in:
zeeZ 2011-05-17 02:38:49 +02:00
parent 70dead3fb9
commit ccbd6bf45e
13 changed files with 60 additions and 48 deletions

View file

@ -6,6 +6,7 @@ import java.util.logging.Logger;
public class BoundInputStream extends InputStream {
protected static final Logger log = Logger.getLogger("Minecraft");
protected static final String LOG_PREFIX = "[dynmap] ";
private InputStream base;
private long bound;

View file

@ -12,6 +12,7 @@ import java.util.logging.Logger;
public class HttpServer extends Thread {
protected static final Logger log = Logger.getLogger("Minecraft");
protected static final String LOG_PREFIX = "[dynmap] ";
private ServerSocket sock = null;
private Thread listeningThread;
@ -30,7 +31,7 @@ public class HttpServer extends Thread {
sock = new ServerSocket(port, 5, bindAddress);
listeningThread = this;
start();
log.info("Dynmap WebServer started on " + bindAddress + ":" + port);
log.info(LOG_PREFIX + "Dynmap WebServer started on " + bindAddress + ":" + port);
}
public void run() {
@ -41,24 +42,24 @@ public class HttpServer extends Thread {
HttpServerConnection requestThread = new HttpServerConnection(socket, this);
requestThread.start();
} catch (IOException e) {
log.info("map WebServer.run() stops with IOException");
log.info(LOG_PREFIX + "map WebServer.run() stops with IOException");
break;
}
}
log.info("Webserver shut down.");
log.info(LOG_PREFIX + "Webserver shut down.");
} catch (Exception ex) {
log.log(Level.SEVERE, "Exception on WebServer-thread", ex);
log.log(Level.SEVERE, LOG_PREFIX + "Exception on WebServer-thread", ex);
}
}
public void shutdown() {
log.info("Shutting down webserver...");
log.info(LOG_PREFIX + "Shutting down webserver...");
try {
if (sock != null) {
sock.close();
}
} catch (IOException e) {
log.log(Level.INFO, "Exception while closing socket for webserver shutdown", e);
log.log(Level.INFO, LOG_PREFIX + "Exception while closing socket for webserver shutdown", e);
}
listeningThread = null;
}

View file

@ -18,6 +18,7 @@ import org.dynmap.debug.Debug;
public class HttpServerConnection extends Thread {
protected static final Logger log = Logger.getLogger("Minecraft");
protected static final String LOG_PREFIX = "[dynmap] ";
private static Pattern requestHeaderLine = Pattern.compile("^(\\S+)\\s+(\\S+)\\s+HTTP/(.+)$");
private static Pattern requestHeaderField = Pattern.compile("^([^:]+):\\s*(.+)$");
@ -174,7 +175,7 @@ public class HttpServerConnection extends Thread {
} catch (IOException e) {
throw e;
} catch (Exception e) {
log.log(Level.SEVERE, "HttpHandler '" + handler + "' has thown an exception", e);
log.log(Level.SEVERE, LOG_PREFIX + "HttpHandler '" + handler + "' has thown an exception", e);
if (socket != null) {
out.flush();
socket.close();
@ -228,7 +229,7 @@ public class HttpServerConnection extends Thread {
} catch (IOException ex) {
}
}
log.log(Level.SEVERE, "Exception while handling request: ", e);
log.log(Level.SEVERE, LOG_PREFIX + "Exception while handling request: ", e);
e.printStackTrace();
return;
}

View file

@ -15,6 +15,7 @@ import org.dynmap.web.HttpStatus;
public abstract class FileHandler implements HttpHandler {
protected static final Logger log = Logger.getLogger("Minecraft");
protected static final String LOG_PREFIX = "[dynmap] ";
private byte[] readBuffer = new byte[40960];
private static Map<String, String> mimes = new HashMap<String, String>();

View file

@ -17,6 +17,7 @@ import org.json.simple.parser.JSONParser;
public class SendMessageHandler implements HttpHandler {
protected static final Logger log = Logger.getLogger("Minecraft");
protected static final String LOG_PREFIX = "[dynmap] ";
private static final JSONParser parser = new JSONParser();
public Event<Message> onMessageReceived = new Event<SendMessageHandler.Message>();