cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sylv...@apache.org
Subject svn commit: r291122 - in /cocoon/trunk/src/java/org/apache/cocoon/util: location/LocatedException.java log/CocoonLogFormatter.java
Date Fri, 23 Sep 2005 14:17:23 GMT
Author: sylvain
Date: Fri Sep 23 07:17:18 2005
New Revision: 291122

URL: http://svn.apache.org/viewcvs?rev=291122&view=rev
Log:
Fix (hopefully) logging of stacktraces

Modified:
    cocoon/trunk/src/java/org/apache/cocoon/util/location/LocatedException.java
    cocoon/trunk/src/java/org/apache/cocoon/util/log/CocoonLogFormatter.java

Modified: cocoon/trunk/src/java/org/apache/cocoon/util/location/LocatedException.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/util/location/LocatedException.java?rev=291122&r1=291121&r2=291122&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/util/location/LocatedException.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/util/location/LocatedException.java Fri Sep 23
07:17:18 2005
@@ -68,7 +68,7 @@
      * This is needed because some exceptions (e.g. SAXException) don't have a getCause()
that is
      * used to print stacktraces.
      */
-    static void ensureCauseChainIsSet(Throwable thr) {
+    public static void ensureCauseChainIsSet(Throwable thr) {
         if (INIT_CAUSE_METHOD == null)
             return;
         
@@ -79,7 +79,7 @@
                 try {
                     INIT_CAUSE_METHOD.invoke(thr, new Object[]{ parent });
                 } catch(Exception e) {
-                    // unlikely, so ignore
+                    // can happen if parent already set on exception
                 }
             }
             thr = parent;

Modified: cocoon/trunk/src/java/org/apache/cocoon/util/log/CocoonLogFormatter.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/util/log/CocoonLogFormatter.java?rev=291122&r1=291121&r2=291122&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/util/log/CocoonLogFormatter.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/util/log/CocoonLogFormatter.java Fri Sep 23 07:17:18
2005
@@ -20,6 +20,7 @@
 
 import org.apache.cocoon.environment.ObjectModelHelper;
 import org.apache.cocoon.environment.Request;
+import org.apache.cocoon.util.location.LocatedException;
 
 import org.apache.commons.lang.ClassUtils;
 import org.apache.commons.lang.exception.ExceptionUtils;
@@ -76,6 +77,7 @@
     protected final static String  TYPE_ROOTTHROWABLE_STR = "rootThrowable";
 
     private static final String DEFAULT_TIME_PATTERN = "(yyyy-MM-dd) HH:mm.ss:SSS";
+    private static final FastDateFormat dateFormatter = FastDateFormat.getInstance(DEFAULT_TIME_PATTERN);
 
     /**
      * Hack to get the call stack as an array of classes. The
@@ -288,7 +290,9 @@
      */
     protected String getStackTrace(final Throwable throwable, final String format) {
         if (throwable != null) {
-            return ExceptionUtil.printStackTrace(throwable, m_stackDepth);
+            LocatedException.ensureCauseChainIsSet(throwable);
+            return ExceptionUtils.getStackTrace(throwable);
+            //return ExceptionUtil.printStackTrace(throwable, m_stackDepth);
         }
 
         return null;
@@ -302,13 +306,9 @@
      * @return the formatted string
      */
     protected String getTime(final long time, String pattern) {
-        String result;
-
-        if (pattern == null) {
-            pattern = DEFAULT_TIME_PATTERN;
+        if (pattern == null || DEFAULT_TIME_PATTERN.equals(pattern)) {
+            return dateFormatter.format(time);
         }
-        FastDateFormat format = FastDateFormat.getInstance(pattern);
-        result = format.format(time);
-        return result;
+        return FastDateFormat.getInstance(pattern).format(time);
     }
 }



Mime
View raw message