jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject [1/3] jena git commit: JENA-1565: Print the throwable and stacktrace
Date Mon, 25 Jun 2018 10:32:54 GMT
Repository: jena
Updated Branches:
  refs/heads/master 941381b36 -> 3d9b16770


JENA-1565: Print the throwable and stacktrace


Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/842b4a7f
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/842b4a7f
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/842b4a7f

Branch: refs/heads/master
Commit: 842b4a7ffc3492e31c28230cb5a976706a79e9f7
Parents: 941381b
Author: Andy Seaborne <andy@apache.org>
Authored: Mon Jun 25 11:00:07 2018 +0100
Committer: Andy Seaborne <andy@apache.org>
Committed: Mon Jun 25 11:00:07 2018 +0100

----------------------------------------------------------------------
 .../jena/atlas/logging/java/TextFormatter.java    | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/842b4a7f/jena-base/src/main/java/org/apache/jena/atlas/logging/java/TextFormatter.java
----------------------------------------------------------------------
diff --git a/jena-base/src/main/java/org/apache/jena/atlas/logging/java/TextFormatter.java
b/jena-base/src/main/java/org/apache/jena/atlas/logging/java/TextFormatter.java
index eb3b3a4..286c4c1 100644
--- a/jena-base/src/main/java/org/apache/jena/atlas/logging/java/TextFormatter.java
+++ b/jena-base/src/main/java/org/apache/jena/atlas/logging/java/TextFormatter.java
@@ -18,7 +18,9 @@
 
 package org.apache.jena.atlas.logging.java;
 
-import java.text.MessageFormat ;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.text.MessageFormat;
 import java.util.Date ;
 import java.util.logging.Formatter ;
 import java.util.logging.Level ;
@@ -89,6 +91,18 @@ public class TextFormatter extends Formatter
         if ( record.getParameters() != null )
             formatted$ = MessageFormat.format(formatted$, record.getParameters()) ;
         
+        String throwable = "";
+        Throwable th = record.getThrown();
+        if ( th != null ) {
+            // Avoid going via bytes because of the risk of platform character set issues.
+            StringWriter sw = new StringWriter();
+            try ( PrintWriter pw = new PrintWriter(sw) ) {
+                pw.println();
+                th.printStackTrace(pw);
+            }
+            formatted$ = formatted$ + sw.toString();
+        }
+        
         Level level = record.getLevel() ;
         String levelOutputName = levelOutputName(level) ;
         
@@ -98,7 +112,7 @@ public class TextFormatter extends Formatter
                              levelOutputName,                   // 3
                              Thread.currentThread().getName(),  // 4
                              new Date(record.getMillis()),      // 5
-                             formatted$) ;                      // 6
+                             formatted$);                       // 6
     }
 
     /** By default use slf4j name.


Mime
View raw message