You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-cvs@jakarta.apache.org by pa...@apache.org on 2001/05/01 00:51:48 UTC
cvs commit: jakarta-log4j/src/java/org/apache/log4j HTMLLayout.java
pathos 01/04/30 15:51:48
Modified: src/java/org/apache/log4j HTMLLayout.java
Log:
Beautified layout, NDC is now printed below the message if not null, some small changes
Revision Changes Path
1.19 +30 -22 jakarta-log4j/src/java/org/apache/log4j/HTMLLayout.java
Index: HTMLLayout.java
===================================================================
RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/HTMLLayout.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- HTMLLayout.java 2001/04/29 13:48:59 1.18
+++ HTMLLayout.java 2001/04/30 22:51:46 1.19
@@ -124,7 +124,7 @@
The <b>Title</b> option takes a String value. This option sets the
document title of the generated HTML document.
- <p>Defaults to 'Log4J Logging Statements'.
+ <p>Defaults to 'Log4J Log Messages'.
*/
public
void setTitle(String title) {
@@ -169,13 +169,18 @@
sbuf.append(event.timeStamp - event.getStartTime());
sbuf.append("</td>" + Layout.LINE_SEP);
- sbuf.append("<td>");
+ sbuf.append("<td title=\"" + event.getThreadName() + " thread\">");
sbuf.append(escapeHTMLTags(event.getThreadName()));
sbuf.append("</td>" + Layout.LINE_SEP);
- sbuf.append("<td>");
- if(event.priority.isGreaterOrEqual(Priority.WARN)) {
- sbuf.append("<font color=\"#FF0000\"><strong>");
+ sbuf.append("<td title=\"Priority\">");
+ if (event.priority.equals(Priority.DEBUG)) {
+ sbuf.append("<font color=\"#339933\">");
+ sbuf.append(event.priority);
+ sbuf.append("</font>");
+ }
+ else if(event.priority.isGreaterOrEqual(Priority.WARN)) {
+ sbuf.append("<font color=\"#993300\"><strong>");
sbuf.append(event.priority);
sbuf.append("</strong></font>");
} else {
@@ -183,14 +188,10 @@
}
sbuf.append("</td>" + Layout.LINE_SEP);
- sbuf.append("<td>");
+ sbuf.append("<td title=\"" + event.categoryName + " category\">");
sbuf.append(escapeHTMLTags(event.categoryName));
sbuf.append("</td>" + Layout.LINE_SEP);
- sbuf.append("<td>");
- sbuf.append(escapeHTMLTags(event.getNDC()));
- sbuf.append("</td>" + Layout.LINE_SEP);
-
if(locationInfo) {
LocationInfo locInfo = event.getLocationInformation();
sbuf.append("<td>");
@@ -200,14 +201,20 @@
sbuf.append("</td>" + Layout.LINE_SEP);
}
- sbuf.append("<td>");
+ sbuf.append("<td title=\"Message\">");
sbuf.append(escapeHTMLTags(event.getRenderedMessage()));
sbuf.append("</td>" + Layout.LINE_SEP);
sbuf.append("</tr>" + Layout.LINE_SEP);
+ if (event.getNDC() != null) {
+ sbuf.append("<tr><td bgcolor=\"#EEEEEE\" style=\"font-size : xx-small;\" colspan=\"6\" title=\"Nested Diagnostic Context\">");
+ sbuf.append("NDC: " + escapeHTMLTags(event.getNDC()));
+ sbuf.append("</td></tr>" + Layout.LINE_SEP);
+ }
+
String[] s = event.getThrowableStrRep();
if(s != null) {
- sbuf.append("<tr><td bgcolor=\"#EEEEEE\" style=\"font-size : xx-small;\" colspan=\"7\">");
+ sbuf.append("<tr><td bgcolor=\"#993300\" style=\"color:White; font-size : xx-small;\" colspan=\"6\">");
appendThrowableAsHTML(s, sbuf);
sbuf.append("</td></tr>" + Layout.LINE_SEP);
}
@@ -242,21 +249,21 @@
sbuf.append("<title>" + title + "</title>" + Layout.LINE_SEP);
sbuf.append("<style type=\"text/css\">" + Layout.LINE_SEP);
sbuf.append("<!--" + Layout.LINE_SEP);
- sbuf.append("body {font-family: arial,sans-serif; font-size: x-small;}" + Layout.LINE_SEP);
+ sbuf.append("body, table {font-family: arial,sans-serif; font-size: x-small;}" + Layout.LINE_SEP);
sbuf.append("th {background: #336699; color: #FFFFFF; text-align: left;}" + Layout.LINE_SEP);
sbuf.append("-->" + Layout.LINE_SEP);
sbuf.append("</style>" + Layout.LINE_SEP);
sbuf.append("</head>" + Layout.LINE_SEP);
sbuf.append("<body bgcolor=\"#FFFFFF\" topmargin=\"6\" leftmargin=\"6\">" + Layout.LINE_SEP);
- sbuf.append(new java.util.Date() + ":<br>" + Layout.LINE_SEP);
+ sbuf.append("<hr size=\"1\" noshade>" + Layout.LINE_SEP);
+ sbuf.append("Log session start time " + new java.util.Date() + "<br>" + Layout.LINE_SEP);
sbuf.append("<br>" + Layout.LINE_SEP);
- sbuf.append("<table cellspacing=\"0\" cellpadding=\"6\" border=\"1\" bordercolor=\"#224466\" bgcolor=\"#FFFFFF\" width=\"100%\">" + Layout.LINE_SEP);
+ sbuf.append("<table cellspacing=\"0\" cellpadding=\"4\" border=\"1\" bordercolor=\"#224466\" width=\"100%\">" + Layout.LINE_SEP);
sbuf.append("<tr>" + Layout.LINE_SEP);
sbuf.append("<th>Time</th>" + Layout.LINE_SEP);
sbuf.append("<th>Thread</th>" + Layout.LINE_SEP);
sbuf.append("<th>Priority</th>" + Layout.LINE_SEP);
sbuf.append("<th>Category</th>" + Layout.LINE_SEP);
- sbuf.append("<th>NDC</th>" + Layout.LINE_SEP);
if(locationInfo) {
sbuf.append("<th>File:Line</th>" + Layout.LINE_SEP);
}
@@ -308,18 +315,19 @@
StringBuffer buf = new StringBuffer(input.length() + 6);
char ch = ' ';
- for( int i=0; i < input.length(); i++ ) {
+ for(int i=0; i < input.length(); i++) {
ch = input.charAt(i);
- if( ch == '<' ) {
- buf.append( "<" );
+ if(ch == '<') {
+ buf.append("<");
}
- else if( ch == '>' ) {
- buf.append( ">" );
+ else if(ch == '>') {
+ buf.append(">");
}
else {
- buf.append( ch );
+ buf.append(ch);
}
}
+
return buf.toString();
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-cvs-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-cvs-help@jakarta.apache.org