You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by sy...@apache.org on 2005/09/23 16:17:23 UTC
svn commit: r291122 - in /cocoon/trunk/src/java/org/apache/cocoon/util:
location/LocatedException.java log/CocoonLogFormatter.java
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);
}
}