HTMLLayout2.java 文件源码

java
阅读 23 收藏 0 点赞 0 评论 0

项目:Equella 作者:
@Override
public String format(LoggingEvent event)
{
    if( sbuf.capacity() > 1024 )
    {
        sbuf = new StringBuilder(256);
    }
    else
    {
        sbuf.setLength(0);
    }
    sbuf.append(Layout.LINE_SEP);
    sbuf.append("<tr>");
    sbuf.append(Layout.LINE_SEP);
    sbuf.append("<td>");
    sbuf.append(dateFormat.format(new Date(event.timeStamp)));
    sbuf.append("</td>");
    sbuf.append(Layout.LINE_SEP);
    sbuf.append("<td>");
    if( event.getLevel().equals(Level.DEBUG) )
    {
        sbuf.append("<font color=\"#339933\">");
        sbuf.append(event.getLevel());
        sbuf.append("</font>");
    }
    else if( event.getLevel().isGreaterOrEqual(Level.WARN) )
    {
        sbuf.append("<font color=\"#993300\"><strong>");
        sbuf.append(event.getLevel());
        sbuf.append("</strong></font>");
    }
    else
    {
        sbuf.append(event.getLevel());
    }
    sbuf.append("</td>");
    sbuf.append(Layout.LINE_SEP);
    sbuf.append("<td>");
    sbuf.append(Transform.escapeTags(event.getLoggerName()));
    sbuf.append("</td>");
    sbuf.append(Layout.LINE_SEP);
    if( locationInfo )
    {
        LocationInfo locInfo = event.getLocationInformation();
        sbuf.append("<td>");
        sbuf.append(Transform.escapeTags(locInfo.getFileName()));
        sbuf.append(':');
        sbuf.append(locInfo.getLineNumber());
        sbuf.append("</td>");
        sbuf.append(Layout.LINE_SEP);
    }
    sbuf.append("<td>");
    sbuf.append(Transform.escapeTags(event.getRenderedMessage()));
    sbuf.append("</td>");
    sbuf.append(Layout.LINE_SEP);
    sbuf.append("</tr>");
    sbuf.append(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: ");
        sbuf.append(Transform.escapeTags(event.getNDC()));
        sbuf.append("</td></tr>");
        sbuf.append(Layout.LINE_SEP);
    }
    String s[] = event.getThrowableStrRep();
    if( s != null )
    {
        sbuf.append("<tr><td bgcolor=\"#993300\" style=\"color:White; font-size : xx-small;\" colspan=\"6\">");
        appendThrowableAsHTML(s, sbuf);
        sbuf.append("</td></tr>");
        sbuf.append(Layout.LINE_SEP);
    }
    return sbuf.toString();
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号