summaryrefslogtreecommitdiffstats
path: root/vespalog
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@yahoo-inc.com>2017-04-25 15:39:27 +0200
committerJon Bratseth <bratseth@yahoo-inc.com>2017-04-25 15:39:27 +0200
commitbd36566986e66cf046a1bd3f5abe4cc6b9f4f149 (patch)
tree85d6d418d993211ffdf705900d17ac55fc4c27ac /vespalog
parentd46f324c29c7200928f6e5ae9ba8196e7b461849 (diff)
Add /nodes/v2/maintenance
Diffstat (limited to 'vespalog')
-rw-r--r--vespalog/src/main/java/com/yahoo/log/VespaFormatter.java35
1 files changed, 34 insertions, 1 deletions
diff --git a/vespalog/src/main/java/com/yahoo/log/VespaFormatter.java b/vespalog/src/main/java/com/yahoo/log/VespaFormatter.java
index ee0f6e90b7c..b6a63c52321 100644
--- a/vespalog/src/main/java/com/yahoo/log/VespaFormatter.java
+++ b/vespalog/src/main/java/com/yahoo/log/VespaFormatter.java
@@ -137,7 +137,8 @@ public class VespaFormatter extends SimpleFormatter {
private void appendException(Throwable throwable, StringBuilder builder) {
if (throwable == null)
return;
-
+//throwable.printStackTrace();
+if (1==1) return;
String escapedStackTrace = VespaFormat.escape(stackTrace(throwable));
builder.append("\\n").append("exception=").append("\\n").append(escapedStackTrace);
}
@@ -169,4 +170,36 @@ public class VespaFormatter extends SimpleFormatter {
public String getServiceName () {
return serviceName;
}
+
+
+ public static String toMessageString(Throwable t) {
+ StringBuilder b = new StringBuilder();
+ String lastMessage = null;
+ String message;
+ for (; t != null; t = t.getCause()) {
+ message = getMessage(t);
+ if (message == null) continue;
+ if (message.equals(lastMessage)) continue;
+ if (b.length() > 0) {
+ b.append(": ");
+ }
+ b.append(message);
+ lastMessage = message;
+ }
+ return b.toString();
+ }
+
+ /** Returns a useful message from *this* exception, or null if there is nothing useful to return */
+ private static String getMessage(Throwable t) {
+ String message = t.getMessage();
+ if (t.getCause() == null) {
+ if (message == null) return t.getClass().getSimpleName();
+ } else {
+ if (message == null) return null;
+ //if (message.equals(t.getCause().getClass().getName() + ": " + t.getCause().getMessage())) return null;
+ }
+ return message;
+ }
+
+
}