View Javadoc

1   /**
2    * Logback: the reliable, generic, fast and flexible logging framework.
3    * Copyright (C) 1999-2009, QOS.ch. All rights reserved.
4    *
5    * This program and the accompanying materials are dual-licensed under
6    * either the terms of the Eclipse Public License v1.0 as published by
7    * the Eclipse Foundation
8    *
9    *   or (per the licensee's choosing)
10   *
11   * under the terms of the GNU Lesser General Public License version 2.1
12   * as published by the Free Software Foundation.
13   */
14  package ch.qos.logback.access.html;
15  
16  import static ch.qos.logback.core.CoreConstants.LINE_SEPARATOR;
17  import ch.qos.logback.core.html.CssBuilder;
18  
19  /**
20   * This class helps the HTMLLayout build the CSS link. It either provides the
21   * HTMLLayout with a default css file, or builds the link to an external,
22   * user-specified, file.
23   * 
24   * @author Sébastien Pennec
25   */
26  public class DefaultCssBuilder implements CssBuilder {
27  
28    public DefaultCssBuilder() {
29    }
30  
31    public void addCss(StringBuilder sbuf) {
32      sbuf.append("<style  type=\"text/css\">");
33      sbuf.append("table{ ");
34      sbuf.append("margin-left: 2em; ");
35      sbuf.append("margin-right: 2em; ");
36      sbuf.append("border-left: 2px solid #AAA; ");
37      sbuf.append("}");
38      sbuf.append(LINE_SEPARATOR);
39      sbuf.append("TR.even { ");
40      sbuf.append("background: #FFFFFF; ");
41      sbuf.append("}");
42      sbuf.append(LINE_SEPARATOR);
43      sbuf.append("TR.odd { ");
44      sbuf.append("background: #EAEAEA; ");
45      sbuf.append("}");
46      sbuf.append(LINE_SEPARATOR);
47      sbuf.append("TD {");
48      sbuf.append("padding-right: 1ex; ");
49      sbuf.append("padding-left: 1ex; ");
50      sbuf.append("border-right: 2px solid #AAA;");
51      sbuf.append("}");
52      sbuf.append(LINE_SEPARATOR);
53      sbuf.append("TD.Time, TD.Date { ");
54      sbuf.append("text-align: right; ");
55      sbuf.append("font-family: courier, monospace; ");
56      sbuf.append("font-size: smaller; ");
57      sbuf.append("}");
58      sbuf.append(LINE_SEPARATOR);
59      sbuf
60          .append("TD.RemoteHost, TD.RequestProtocol, TD.RequestHeader, TD.RequestURL, TD.RemoteUser, TD.RequestURI, TD.ServerName {");
61      sbuf.append("text-align: left; ");
62      sbuf.append("}");
63      sbuf.append(LINE_SEPARATOR);
64      sbuf
65          .append("TD.RequestAttribute, TD.RequestCookie, TD.ResponseHeader, TD.RequestParameter {");
66      sbuf.append("text-align: left; ");
67      sbuf.append("}");
68      sbuf.append(LINE_SEPARATOR);
69      sbuf
70          .append("TD.RemoteIPAddress, TD.LocalIPAddress, TD.ContentLength, TD.StatusCode, TD.LocalPort {");
71      sbuf.append("text-align: right; ");
72      sbuf.append("}");
73      sbuf.append(LINE_SEPARATOR);
74      sbuf.append("TR.header { ");
75      sbuf.append("background: #596ED5; ");
76      sbuf.append("color: #FFF; ");
77      sbuf.append("font-weight: bold; ");
78      sbuf.append("font-size: larger; ");
79      sbuf.append("}");
80      sbuf.append(LINE_SEPARATOR);
81      sbuf.append("</style>");
82    }
83  }