Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Logback: the reliable, generic, fast and flexible logging framework. Copyright (C) 1999-2011, All rights reserved. This program and the accompanying materials are dual-licensed under either the terms of the Eclipse Public License v1.0 as published by the Eclipse Foundation or (per the licensee's choosing) under the terms of the GNU Lesser General Public License version 2.1 as published by the Free Software Foundation.
 package ch.qos.logback.core.status;
 import static ch.qos.logback.core.CoreConstants.LINE_SEPARATOR;
 import java.util.List;
 abstract public class ViewStatusMessagesServletBase extends HttpServlet {
   private static final long serialVersionUID = -3551928133801157219L;
   private static CachingDateFormatter SDF = new CachingDateFormatter(
       "yyyy-MM-dd HH:mm:ss");
   static String SUBMIT = "submit";
   static String CLEAR = "Clear";
   protected abstract StatusManager getStatusManager(HttpServletRequest reqHttpServletResponse resp);
   protected abstract String getPageTitle(HttpServletRequest reqHttpServletResponse resp);
   int count;
   protected void service(HttpServletRequest reqHttpServletResponse resp)
       throws ServletExceptionIOException {
      = 0;
     StatusManager sm = getStatusManager(reqresp);
     PrintWriter output = resp.getWriter();
     printCSS(req.getContextPath(), output);
     output.append("<form method=\"POST\">\r\n");
     output.append("<input type=\"submit\" name=\""++"\" value=\""++"\">");
       sm.add(new InfoStatus("Cleared all status messages"this));
     StringBuilder buf = new StringBuilder();
     if(sm != null) {
     } else {
       output.append("Could not find status manager");
   public void printCSS(String localRefPrintWriter output) {
     output.append("  <STYLE TYPE=\"text/css\">\r\n");
     output.append("    .warn  { font-weight: bold; color: #FF6600;} \r\n"); // orange
     output.append("    .error { font-weight: bold; color: #CC0000;} \r\n");
         .append("    table { margin-left: 2em; margin-right: 2em; border-left: 2px solid #AAA; }\r\n");
     output.append("    tr.even { background: #FFFFFF; }\r\n");
     output.append("    tr.odd  { background: #EAEAEA; }\r\n");
         .append("    td { padding-right: 1ex; padding-left: 1ex; border-right: 2px solid #AAA; }\r\n");
        .append(" { text-align: right; font-family: courier, monospace; font-size: smaller; }");
    output.append("  td.level { text-align: right; }");
        .append("    tr.header { background: #596ED5; color: #FFF; font-weight: bold; font-size: larger; }");
        .append("  td.exception { background: #A2AEE8; white-space: pre; font-family: courier, monospace;}");
    output.append("  </STYLE>\r\n");
  public void printList(StringBuilder bufStatusManager sm) {
    List<StatusstatusList = sm.getCopyOfStatusList();
    for (Status s : statusList) {
  public void printHeader(StringBuilder buf) {
    buf.append("  <tr class=\"header\">\r\n");
    buf.append("    <th>Date </th>\r\n");
    buf.append("    <th>Level</th>\r\n");
    buf.append("    <th>Origin</th>\r\n");
    buf.append("    <th>Message</th>\r\n");
    buf.append("  </tr>\r\n");
    switch (s.getEffectiveLevel()) {
    case .:
      return "INFO";
    case .:
      return "<span class=\"warn\">WARN</span>";
    case .:
      return "<span class=\"error\">ERROR</span>";
    return null;
    Object o = s.getOrigin();
    if (o == null) {
      return null;
    String fqClassName = o.getClass().getName();
    int lastIndex = fqClassName.lastIndexOf(.);
    if (lastIndex != -1) {
      return fqClassName.substring(lastIndex + 1, fqClassName.length());
    } else {
      return fqClassName;
  private void printStatus(StringBuilder bufStatus s) {
    String trClass;
    if ( % 2 == 0) {
      trClass = "even";
    } else {
      trClass = "odd";
    buf.append("  <tr class=\"").append(trClass).append("\">\r\n");
    String dateStr = .format(s.getDate());
    buf.append("    <td class=\"date\">").append(dateStr).append("</td>\r\n");
    buf.append("    <td class=\"level\">").append(statusLevelAsString(s))
    buf.append("    <td>").append(abbreviatedOrigin(s)).append("</td>\r\n");
    buf.append("    <td>").append(s.getMessage()).append("</td>\r\n");
    buf.append("  </tr>\r\n");
    if (s.getThrowable() != null) {
  private void printThrowable(StringBuilder bufThrowable t) {
    buf.append("  <tr>\r\n");
    buf.append("    <td colspan=\"4\" class=\"exception\"><pre>");
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    buf.append("    </pre></td>\r\n");
    buf.append("  </tr>\r\n");
New to GrepCode? Check out our FAQ X