logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgo...@apache.org
Subject svn commit: r1400491 - in /logging/log4j/log4j2/trunk/core/src: main/java/org/apache/logging/log4j/core/layout/HTMLLayout.java test/java/org/apache/logging/log4j/core/layout/HTMLLayoutTest.java
Date Sat, 20 Oct 2012 17:29:51 GMT
Author: rgoers
Date: Sat Oct 20 17:29:51 2012
New Revision: 1400491

URL: http://svn.apache.org/viewvc?rev=1400491&view=rev
Log:
LOG4J2-29 - Replace newline in message with br tag

Modified:
    logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/layout/HTMLLayout.java
    logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/layout/HTMLLayoutTest.java

Modified: logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/layout/HTMLLayout.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/layout/HTMLLayout.java?rev=1400491&r1=1400490&r2=1400491&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/layout/HTMLLayout.java
(original)
+++ logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/layout/HTMLLayout.java
Sat Oct 20 17:29:51 2012
@@ -45,7 +45,7 @@ public final class HTMLLayout extends Ab
 
     private static final int BUF_SIZE = 256;
 
-    private static final String TRACE_PREFIX = "<br>&nbsp;&nbsp;&nbsp;&nbsp;";
+    private static final String TRACE_PREFIX = "<br />&nbsp;&nbsp;&nbsp;&nbsp;";
 
     private static final String LINE_SEP = System.getProperty("line.separator");
 
@@ -157,7 +157,7 @@ public final class HTMLLayout extends Ab
         }
 
         sbuf.append("<td title=\"Message\">");
-        sbuf.append(Transform.escapeTags(event.getMessage().getFormattedMessage()));
+        sbuf.append(Transform.escapeTags(event.getMessage().getFormattedMessage()).replaceAll(LINE_SEP,
"<br />"));
         sbuf.append("</td>").append(LINE_SEP);
         sbuf.append("</tr>").append(LINE_SEP);
 

Modified: logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/layout/HTMLLayoutTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/layout/HTMLLayoutTest.java?rev=1400491&r1=1400490&r2=1400491&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/layout/HTMLLayoutTest.java
(original)
+++ logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/layout/HTMLLayoutTest.java
Sat Oct 20 17:29:51 2012
@@ -56,6 +56,9 @@ public class HTMLLayoutTest {
     private static final String body =
         "<tr><td bgcolor=\"#993300\" style=\"color:White; font-size : small;\" colspan=\"6\">java.lang.NullPointerException:
test";
 
+    private static final String multiLine =
+        "<td title=\"Message\">First line<br />Second line</td>";
+
 
     /**
      * Test case for MDC conversion pattern.
@@ -77,6 +80,8 @@ public class HTMLLayoutTest {
 
         root.debug("empty mdc");
 
+        root.debug("First line\nSecond line");
+
         ThreadContext.put("key1", "value1");
         ThreadContext.put("key2", "value2");
 
@@ -93,7 +98,8 @@ public class HTMLLayoutTest {
         assertTrue("Incorrect number of lines. Require at least 85 " + list.size(), list.size()
> 85);
         assertTrue("Incorrect header", list.get(3).equals("<title>Log4J Log Messages</title>"));
         assertTrue("Incorrect footer", list.get(list.size() - 1).equals("</body></html>"));
-        assertTrue("Incorrect body", list.get(61).equals(body));
+        assertTrue("Incorrect multiline", list.get(49).equals(multiLine));
+        assertTrue("Incorrect body", list.get(70).equals(body));
 
     }
 }



Mime
View raw message