X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fnet%2Fpterodactylus%2Futil%2Flogging%2FLogging.java;h=ef8bb6a5dde14c9743d45862cf1215972843d084;hb=314c651f13963682d47636c01e49a044222035e4;hp=fe2fb54ca75a2bb78e400df4eeefd0cbc1491fe3;hpb=03c0530e4536d194afa0556c45e07f4d4df35439;p=jSite2.git diff --git a/src/net/pterodactylus/util/logging/Logging.java b/src/net/pterodactylus/util/logging/Logging.java index fe2fb54..ef8bb6a 100644 --- a/src/net/pterodactylus/util/logging/Logging.java +++ b/src/net/pterodactylus/util/logging/Logging.java @@ -91,10 +91,29 @@ public class Logging { @Override public synchronized String format(LogRecord record) { recordBuffer.setLength(0); - recordBuffer.append(dateFormatter.format(new Date(record.getMillis()))).append(' ').append(record.getLevel().getName()).append(' '); - recordBuffer.append(record.getSourceClassName()).append('.').append(record.getSourceMethodName()).append(' '); - recordBuffer.append(record.getMessage()); - recordBuffer.append("\r\n"); + String linePrefix = dateFormatter.format(new Date(record.getMillis())) + " [" + record.getLevel() + "] [" + Thread.currentThread().getName() + "] [" + record.getSourceClassName() + "." + record.getSourceMethodName() + "] "; + recordBuffer.append(linePrefix).append(record.getMessage()).append('\n'); + if (record.getThrown() != null) { + Throwable throwable = record.getThrown(); + boolean causedBy = false; + while (throwable != null) { + recordBuffer.append(linePrefix); + if (causedBy) { + recordBuffer.append("caused by: "); + } + recordBuffer.append(throwable.getClass().getName()); + if (throwable.getMessage() != null) { + recordBuffer.append(": ").append(throwable.getMessage()); + } + recordBuffer.append("\n"); + StackTraceElement[] stackTraceElements = throwable.getStackTrace(); + for (StackTraceElement stackTraceElement: stackTraceElements) { + recordBuffer.append(linePrefix).append(" at ").append(stackTraceElement.getClassName()).append('.').append(stackTraceElement.getMethodName()).append("(").append(stackTraceElement.getFileName()).append(':').append(stackTraceElement.getLineNumber()).append(')').append("\n"); + } + throwable = throwable.getCause(); + causedBy = true; + } + } return recordBuffer.toString(); } });