Add thread name and stacktrace to the debug logging (Related to #419)

It's only visible to user who enabled debug logging in their spigot
configuration.
This commit is contained in:
games647 2016-06-01 18:03:54 +02:00
parent e59bbbf10e
commit 351fe3aa5a

View File

@ -11,6 +11,7 @@ import java.io.IOException;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
/** /**
@ -68,9 +69,15 @@ public final class ConsoleLogger {
public static void debug(String message) { public static void debug(String message) {
if (enableDebug) { if (enableDebug) {
logger.fine(message); if (logger.isLoggable(Level.FINE)) {
//creating and filling an exception is a expensive call
logger.log(Level.FINE, message + ' ' + Thread.currentThread().getName(), new Exception());
} else {
logger.log(Level.FINE, "{0} {1}", new Object[]{message, Thread.currentThread().getName()});
}
if (useLogging) { if (useLogging) {
writeLog("Debug: " + message); writeLog("Debug: " + Thread.currentThread().getName() + ':' + message);
} }
} }
} }