[logback-dev] [GIT] Logback: the generic, reliable, fast and flexible logging framework. branch master updated. v_1.0.0-46-g9e59ee9

Gitbot git-noreply at pixie.qos.ch
Tue Nov 8 18:20:19 CET 2011


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Logback: the generic, reliable, fast and flexible logging framework.".

The branch, master has been updated
       via  9e59ee9e868c51467530824e2f06431234a48477 (commit)
       via  fc93571b93062ee4087940abc1f376de42aed9e4 (commit)
       via  9d864bcdc7fae385e4184fa4ceaf114e26718f9b (commit)
       via  71f69c3dc42ce286ab9c8c93385f0801bdb1791f (commit)
       via  245fd65da02ab5a82cb66ae388e56450889eee6f (commit)
       via  9931dfeb2af2e7f629056758772f44c39a43fe99 (commit)
       via  6860c6f5a7e844f213acb222d4c13f5583734cac (commit)
      from  525e3196ee203d2fafe4535a29374dacf7ca90e1 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.qos.ch/gitweb/?p=logback.git;a=commit;h=9e59ee9e868c51467530824e2f06431234a48477
http://github.com/ceki/logback/commit/9e59ee9e868c51467530824e2f06431234a48477

commit 9e59ee9e868c51467530824e2f06431234a48477
Merge: 525e319 fc93571
Author: Ceki Gulcu <ceki at qos.ch>
Date:   Tue Nov 8 18:19:42 2011 +0100

    Merge branch 'master' of github.com:ceki/logback


http://git.qos.ch/gitweb/?p=logback.git;a=commit;h=fc93571b93062ee4087940abc1f376de42aed9e4
http://github.com/ceki/logback/commit/fc93571b93062ee4087940abc1f376de42aed9e4

commit fc93571b93062ee4087940abc1f376de42aed9e4
Merge: cc3ed1a 9d864bc
Author: Jörn Huxhorn <jhuxhorn at googlemail.com>
Date:   Tue Nov 8 07:44:40 2011 -0800

    Merge pull request #33 from ceki/suppressed
    
    Suppressed support in ThrowableProxyUtil.
    
    Updated according to Cekis suggestions.


http://git.qos.ch/gitweb/?p=logback.git;a=commit;h=9d864bcdc7fae385e4184fa4ceaf114e26718f9b
http://github.com/ceki/logback/commit/9d864bcdc7fae385e4184fa4ceaf114e26718f9b

commit 9d864bcdc7fae385e4184fa4ceaf114e26718f9b
Author: Joern Huxhorn <jhuxhorn at googlemail.com>
Date:   Tue Nov 8 16:38:52 2011 +0100

    Added constants for magic values and deprecated unused subjoinSTEPArray method.

diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/spi/ThrowableProxyUtil.java b/logback-classic/src/main/java/ch/qos/logback/classic/spi/ThrowableProxyUtil.java
index 67c3b1b..b89457e 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/spi/ThrowableProxyUtil.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/spi/ThrowableProxyUtil.java
@@ -23,6 +23,9 @@ import ch.qos.logback.core.CoreConstants;
  */
 public class ThrowableProxyUtil {
 
+  public static final int REGULAR_EXCEPTION_INDENT = 1;
+  public static final int SUPPRESSED_EXCEPTION_INDENT = 2;
+
   public static void build(ThrowableProxy nestedTP, Throwable nestedThrowable,
       ThrowableProxy parentTP) {
 
@@ -75,7 +78,7 @@ public class ThrowableProxyUtil {
   public static String asString(IThrowableProxy tp) {
     StringBuilder sb = new StringBuilder();
 
-    recursiveAppend(sb, null, 1, tp);
+    recursiveAppend(sb, null, REGULAR_EXCEPTION_INDENT, tp);
 
     return sb.toString();
   }
@@ -89,10 +92,10 @@ public class ThrowableProxyUtil {
     IThrowableProxy[] suppressed = tp.getSuppressed();
     if(suppressed != null) {
       for(IThrowableProxy current : suppressed) {
-        recursiveAppend(sb, CoreConstants.SUPPRESSED, 2, current);
+        recursiveAppend(sb, CoreConstants.SUPPRESSED, SUPPRESSED_EXCEPTION_INDENT, current);
       }
     }
-    recursiveAppend(sb, CoreConstants.CAUSED_BY, 1, tp.getCause());
+    recursiveAppend(sb, CoreConstants.CAUSED_BY, REGULAR_EXCEPTION_INDENT, tp.getCause());
   }
 
   private static void subjoinFirstLine(StringBuilder buf, String prefix, IThrowableProxy tp) {
@@ -123,11 +126,21 @@ public class ThrowableProxyUtil {
     subjoinPackagingData(sb, step);
   }
 
-  // not called anymore - but it is public
+  /**
+   * @param sb The StringBuilder the STEPs are appended to.
+   * @param tp the IThrowableProxy containing the STEPs.
+   * @deprecated Use subjoinSTEPArray(StringBuilder sb, int indentLevel, IThrowableProxy tp) instead.
+   */
   public static void subjoinSTEPArray(StringBuilder sb, IThrowableProxy tp) {
-    subjoinSTEPArray(sb, 1, tp);
+    // not called anymore - but it is public
+    subjoinSTEPArray(sb, REGULAR_EXCEPTION_INDENT, tp);
   }
 
+  /**
+   * @param sb The StringBuilder the STEPs are appended to.
+   * @param indentLevel indentation level used for the STEPs, usually either REGULAR_EXCEPTION_INDENT or SUPPRESSED_EXCEPTION_INDENT.
+   * @param tp the IThrowableProxy containing the STEPs.
+   */
   private static void subjoinSTEPArray(StringBuilder sb, int indentLevel, IThrowableProxy tp) {
     StackTraceElementProxy[] stepArray = tp.getStackTraceElementProxyArray();
     int commonFrames = tp.getCommonFrames();

http://git.qos.ch/gitweb/?p=logback.git;a=commit;h=71f69c3dc42ce286ab9c8c93385f0801bdb1791f
http://github.com/ceki/logback/commit/71f69c3dc42ce286ab9c8c93385f0801bdb1791f

commit 71f69c3dc42ce286ab9c8c93385f0801bdb1791f
Author: Joern Huxhorn <jhuxhorn at googlemail.com>
Date:   Sat Nov 5 03:53:34 2011 +0100

    Added suppressed-support to asString
    
    Also added two tests that are only executed if running on Java 7.

diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/spi/ThrowableProxyUtil.java b/logback-classic/src/main/java/ch/qos/logback/classic/spi/ThrowableProxyUtil.java
index 8d76786..67c3b1b 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/spi/ThrowableProxyUtil.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/spi/ThrowableProxyUtil.java
@@ -23,7 +23,7 @@ import ch.qos.logback.core.CoreConstants;
  */
 public class ThrowableProxyUtil {
 
-  static public void build(ThrowableProxy nestedTP, Throwable nestedThrowable,
+  public static void build(ThrowableProxy nestedTP, Throwable nestedThrowable,
       ThrowableProxy parentTP) {
 
     StackTraceElement[] nestedSTE = nestedThrowable.getStackTrace();
@@ -72,18 +72,36 @@ public class ThrowableProxyUtil {
     return count;
   }
 
-  static public String asString(IThrowableProxy tp) {
+  public static String asString(IThrowableProxy tp) {
     StringBuilder sb = new StringBuilder();
 
-    while (tp != null) {
-      subjoinFirstLine(sb, tp);
-      sb.append(CoreConstants.LINE_SEPARATOR);
-      subjoinSTEPArray(sb, tp);
-      tp = tp.getCause();
-    }
+    recursiveAppend(sb, null, 1, tp);
+
     return sb.toString();
   }
 
+  private static void recursiveAppend(StringBuilder sb, String prefix, int indent, IThrowableProxy tp) {
+    if(tp == null)
+      return;
+    subjoinFirstLine(sb, prefix, tp);
+    sb.append(CoreConstants.LINE_SEPARATOR);
+    subjoinSTEPArray(sb, indent, tp);
+    IThrowableProxy[] suppressed = tp.getSuppressed();
+    if(suppressed != null) {
+      for(IThrowableProxy current : suppressed) {
+        recursiveAppend(sb, CoreConstants.SUPPRESSED, 2, current);
+      }
+    }
+    recursiveAppend(sb, CoreConstants.CAUSED_BY, 1, tp.getCause());
+  }
+
+  private static void subjoinFirstLine(StringBuilder buf, String prefix, IThrowableProxy tp) {
+    if (prefix != null) {
+      buf.append(prefix);
+    }
+    subjoinExceptionMessage(buf, tp);
+  }
+
   public static void subjoinPackagingData(StringBuilder builder, StackTraceElementProxy step) {
     if (step != null) {
       ClassPackagingData cpd = step.getClassPackagingData();
@@ -100,30 +118,40 @@ public class ThrowableProxyUtil {
     }
   }
   
-  static public void subjoinSTEP(StringBuilder sb, StackTraceElementProxy step) {
+  public static void subjoinSTEP(StringBuilder sb, StackTraceElementProxy step) {
     sb.append(step.toString());
     subjoinPackagingData(sb, step);
   }
-  
-  static public void subjoinSTEPArray(StringBuilder sb, IThrowableProxy tp) {
+
+  // not called anymore - but it is public
+  public static void subjoinSTEPArray(StringBuilder sb, IThrowableProxy tp) {
+    subjoinSTEPArray(sb, 1, tp);
+  }
+
+  private static void subjoinSTEPArray(StringBuilder sb, int indentLevel, IThrowableProxy tp) {
     StackTraceElementProxy[] stepArray = tp.getStackTraceElementProxyArray();
     int commonFrames = tp.getCommonFrames();
 
     for (int i = 0; i < stepArray.length - commonFrames; i++) {
       StackTraceElementProxy step = stepArray[i];
-      sb.append(CoreConstants.TAB);
+      for(int j = 0; j < indentLevel ; j++) {
+        sb.append(CoreConstants.TAB);
+      }
       subjoinSTEP(sb, step);
       sb.append(CoreConstants.LINE_SEPARATOR);
     }
     
     if (commonFrames > 0) {
-      sb.append("\t... ").append(commonFrames).append(" common frames omitted")
+      for(int j = 0; j < indentLevel ; j++) {
+        sb.append(CoreConstants.TAB);
+      }
+      sb.append("... ").append(commonFrames).append(" common frames omitted")
           .append(CoreConstants.LINE_SEPARATOR);
     }
     
   }
 
-  static public void subjoinFirstLine(StringBuilder buf, IThrowableProxy tp) {
+  public static void subjoinFirstLine(StringBuilder buf, IThrowableProxy tp) {
     int commonFrames = tp.getCommonFrames();
     if (commonFrames > 0) {
       buf.append(CoreConstants.CAUSED_BY);
@@ -131,7 +159,7 @@ public class ThrowableProxyUtil {
     subjoinExceptionMessage(buf, tp);
   }
 
-  static public void subjoinFirstLineRootCauseFirst(StringBuilder buf, IThrowableProxy tp) {
+  public static void subjoinFirstLineRootCauseFirst(StringBuilder buf, IThrowableProxy tp) {
     if (tp.getCause() != null) {
       buf.append(CoreConstants.WRAPPED_BY);
     }
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/spi/ThrowableProxyTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/spi/ThrowableProxyTest.java
index 1c485e6..d5ff824 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/spi/ThrowableProxyTest.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/spi/ThrowableProxyTest.java
@@ -14,9 +14,12 @@
 package ch.qos.logback.classic.spi;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assume.assumeNotNull;
 
 import java.io.PrintWriter;
 import java.io.StringWriter;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
 
 import org.junit.After;
 import org.junit.Before;
@@ -27,6 +30,25 @@ public class ThrowableProxyTest {
   StringWriter sw = new StringWriter();
   PrintWriter pw = new PrintWriter(sw);
 
+  private static final Method ADD_SUPPRESSED_METHOD;
+
+  static {
+    Method method = null;
+    try {
+      method = Throwable.class.getMethod("addSuppressed", Throwable.class);
+    } catch (NoSuchMethodException e) {
+      // ignore, will get thrown in Java < 7
+    }
+    ADD_SUPPRESSED_METHOD = method;
+  }
+
+  private static void addSuppressed(Throwable outer, Throwable suppressed) throws InvocationTargetException, IllegalAccessException
+  {
+    if(ADD_SUPPRESSED_METHOD != null) {
+      ADD_SUPPRESSED_METHOD.invoke(outer, suppressed);
+    }
+  }
+
   @Before
   public void setUp() throws Exception {
   }
@@ -71,6 +93,40 @@ public class ThrowableProxyTest {
     verify(w);
   }
 
+  @Test
+  public void suppressed() throws InvocationTargetException, IllegalAccessException
+  {
+    assumeNotNull(ADD_SUPPRESSED_METHOD); // only execute on Java 7, would work anyway but doesn't make sense.
+    Exception ex = null;
+    try {
+      someMethod();
+    } catch (Exception e) {
+      Exception fooException = new Exception("Foo");
+      Exception barException = new Exception("Bar");
+      addSuppressed(e, fooException);
+      addSuppressed(e, barException);
+      ex = e;
+    }
+    verify(ex);
+  }
+
+  @Test
+  public void suppressedWithCause() throws InvocationTargetException, IllegalAccessException
+  {
+    assumeNotNull(ADD_SUPPRESSED_METHOD); // only execute on Java 7, would work anyway but doesn't make sense.
+    Exception ex = null;
+    try {
+      someMethod();
+    } catch (Exception e) {
+      ex=new Exception("Wrapper", e);
+      Exception fooException = new Exception("Foo");
+      Exception barException = new Exception("Bar");
+      addSuppressed(ex, fooException);
+      addSuppressed(e, barException);
+    }
+    verify(ex);
+  }
+
   // see also http://jira.qos.ch/browse/LBCLASSIC-216
   @Test
   public void nullSTE() {

http://git.qos.ch/gitweb/?p=logback.git;a=commit;h=245fd65da02ab5a82cb66ae388e56450889eee6f
http://github.com/ceki/logback/commit/245fd65da02ab5a82cb66ae388e56450889eee6f

commit 245fd65da02ab5a82cb66ae388e56450889eee6f
Author: Joern Huxhorn <jhuxhorn at googlemail.com>
Date:   Sat Nov 5 03:51:33 2011 +0100

    Updated to JUnit 4.10

diff --git a/pom.xml b/pom.xml
index f72f1e0..6f88e10 100755
--- a/pom.xml
+++ b/pom.xml
@@ -32,7 +32,7 @@
     <!-- slf4j.version property is used below, in
          logback-classic/pom.xml and in setClasspath.cmd -->
     <slf4j.version>1.6.4</slf4j.version>
-    <junit.version>4.8.2</junit.version>
+    <junit.version>4.10</junit.version>
     <janino.version>2.5.10</janino.version>
     <scala.version>2.9.1</scala.version>
     <groovy.version>1.7.6</groovy.version>

http://git.qos.ch/gitweb/?p=logback.git;a=commit;h=9931dfeb2af2e7f629056758772f44c39a43fe99
http://github.com/ceki/logback/commit/9931dfeb2af2e7f629056758772f44c39a43fe99

commit 9931dfeb2af2e7f629056758772f44c39a43fe99
Author: Joern Huxhorn <jhuxhorn at googlemail.com>
Date:   Sat Nov 5 03:51:06 2011 +0100

    Added *.ipr and *.iws IDEA files to .gitignore

diff --git a/.gitignore b/.gitignore
index 7e52e85..5e32982 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,4 +4,6 @@ target
 .project
 .idea
 *~
-*.iml
\ No newline at end of file
+*.iml
+*.ipr
+*.iws
\ No newline at end of file

http://git.qos.ch/gitweb/?p=logback.git;a=commit;h=6860c6f5a7e844f213acb222d4c13f5583734cac
http://github.com/ceki/logback/commit/6860c6f5a7e844f213acb222d4c13f5583734cac

commit 6860c6f5a7e844f213acb222d4c13f5583734cac
Author: Joern Huxhorn <jhuxhorn at googlemail.com>
Date:   Sat Nov 5 03:49:13 2011 +0100

    Added SUPPRESSED constant.

diff --git a/logback-core/src/main/java/ch/qos/logback/core/CoreConstants.java b/logback-core/src/main/java/ch/qos/logback/core/CoreConstants.java
index 713879d..cfb3e86 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/CoreConstants.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/CoreConstants.java
@@ -69,6 +69,7 @@ public class CoreConstants {
    */
   public static final Class<?>[] EMPTY_CLASS_ARRAY = new Class[]{};
   public static final String CAUSED_BY = "Caused by: ";
+  public static final String SUPPRESSED = "\tSuppressed: ";
   public static final String WRAPPED_BY = "Wrapped by: ";
 
   public static final char PERCENT_CHAR = '%';

-----------------------------------------------------------------------

Summary of changes:
 .gitignore                                         |    4 +-
 .../logback/classic/spi/ThrowableProxyUtil.java    |   71 +++++++++++++++----
 .../logback/classic/spi/ThrowableProxyTest.java    |   56 +++++++++++++++
 .../java/ch/qos/logback/core/CoreConstants.java    |    1 +
 pom.xml                                            |    2 +-
 5 files changed, 117 insertions(+), 17 deletions(-)


hooks/post-receive
-- 
Logback: the generic, reliable, fast and flexible logging framework.


More information about the logback-dev mailing list