svn commit: r576 - logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/html

Author: seb Date: Wed Sep 13 17:37:34 2006 New Revision: 576 Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/html/HTMLLayout.java logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/html/ThrowableRenderer.java Log: - updated ThrowableRenderer and HTMLLayout. The ThrowableRenderer can be specified in the configuration file. If it is present, it is used to render the Exception in a new line. If no ThrowableRenderer is specified, the user must add a %ex to the pattern used by the HTMLLayout to display Exceptions. Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/html/HTMLLayout.java ============================================================================== --- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/html/HTMLLayout.java (original) +++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/html/HTMLLayout.java Wed Sep 13 17:37:34 2006 @@ -28,9 +28,13 @@ * The content of the table columns are specified using a conversion pattern. * See {@link ch.qos.logback.classic.PatternLayout} for documentation on the * available patterns. - * Note that the pattern <em>%ex</em> used to display an Exception does not need - * to be specified with this layout. An internal {@link ch.qos.logback.classic.html.ThrowableRenderer} is - * called to render the throwable. + * Note that the pattern <em>%ex</em> used to display an Exception is not the only way + * to display an Exception with this layout. + * An internal {@link ch.qos.logback.classic.html.ThrowableRenderer} can be called + * to render the throwable. If a ThrowableRenderer is specified, it is used to render + * the Exception on a new line. + * If no such object is specified to the HTMLLayout, then one must add <em>%ex</em> + * to the pattern to display Exceptions. * <p> * A user-specified external CSS file can be link to the html page. * In case one does not want to custom the html output, an internal CSS @@ -49,6 +53,7 @@ * <layout class="ch.qos.logback.classic.html.HTMLLayout"> * <param name="pattern" value="%relative%thread%mdc%level%class%msg" /> * </layout> + * <throwableRenderer class="ch.qos.logback.classic.html.ThrowableRenderer" /> * <param name="From" value="sender.email@domain.net" /> * <param name="SMTPHost" value="mail.domain.net" /> * <param name="Subject" value="LastEvent: %class - %msg" /> @@ -82,7 +87,7 @@ private CssBuilder cssBuilder; - ThrowableRenderer throwableRenderer = new ThrowableRenderer(); + ThrowableRenderer throwableRenderer; // counter keeping track of the rows output private long counter = 0; @@ -219,10 +224,6 @@ sbuf.append("<tr class=\"header\">"); sbuf.append(LINE_SEP); while (c != null) { - // if (c instanceof ThrowableHandlingConverter) { - // c = c.getNext(); - // continue; - // } name = computeConverterName(c); if (name == null) { c = c.getNext(); @@ -287,7 +288,7 @@ buf.append("</tr>"); buf.append(LINE_SEP); - if (throwableRenderer.newLineRequired(event)) { + if (throwableRenderer != null && event.getThrowableInformation() != null) { buf.append("<tr><td class=\"Exception\" colspan=\"6\">"); throwableRenderer.render(buf, event); buf.append("</td></tr>"); @@ -327,4 +328,13 @@ } } + public ThrowableRenderer getThrowableRenderer() { + return throwableRenderer; + } + + public void setThrowableRenderer(ThrowableRenderer throwableRenderer) { + this.throwableRenderer = throwableRenderer; + } + + } Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/html/ThrowableRenderer.java ============================================================================== --- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/html/ThrowableRenderer.java (original) +++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/html/ThrowableRenderer.java Wed Sep 13 17:37:34 2006 @@ -17,10 +17,6 @@ public void setThrowable(Throwable t) { this.throwable = t; } - - public boolean newLineRequired(LoggingEvent event) { - return event.getThrowableInformation() != null; - } public void render(StringBuffer sbuf, String[] s) { if (s != null) {
participants (1)
-
noreply.seb@qos.ch