1   /**
2    * Logback: the reliable, generic, fast and flexible logging framework.
3    * Copyright (C) 1999-2015, 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.common.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      @Override
29      public void addCss(StringBuilder sbuf) {
30          sbuf.append("<style  type=\"text/css\">");
31          sbuf.append("table{ ");
32          sbuf.append("margin-left: 2em; ");
33          sbuf.append("margin-right: 2em; ");
34          sbuf.append("border-left: 2px solid #AAA; ");
35          sbuf.append("}");
36          sbuf.append(LINE_SEPARATOR);
37          sbuf.append("TR.even { ");
38          sbuf.append("background: #FFFFFF; ");
39          sbuf.append("}");
40          sbuf.append(LINE_SEPARATOR);
41          sbuf.append("TR.odd { ");
42          sbuf.append("background: #EAEAEA; ");
43          sbuf.append("}");
44          sbuf.append(LINE_SEPARATOR);
45          sbuf.append("TD {");
46          sbuf.append("padding-right: 1ex; ");
47          sbuf.append("padding-left: 1ex; ");
48          sbuf.append("border-right: 2px solid #AAA;");
49          sbuf.append("}");
50          sbuf.append(LINE_SEPARATOR);
51          sbuf.append("TD.Time, TD.Date { ");
52          sbuf.append("text-align: right; ");
53          sbuf.append("font-family: courier, monospace; ");
54          sbuf.append("font-size: smaller; ");
55          sbuf.append("}");
56          sbuf.append(LINE_SEPARATOR);
57          sbuf.append(
58                  "TD.RemoteHost, TD.RequestProtocol, TD.RequestHeader, TD.RequestURL, TD.RemoteUser, TD.RequestURI, TD.ServerName {");
59          sbuf.append("text-align: left; ");
60          sbuf.append("}");
61          sbuf.append(LINE_SEPARATOR);
62          sbuf.append("TD.RequestAttribute, TD.RequestCookie, TD.ResponseHeader, TD.RequestParameter {");
63          sbuf.append("text-align: left; ");
64          sbuf.append("}");
65          sbuf.append(LINE_SEPARATOR);
66          sbuf.append("TD.RemoteIPAddress, TD.LocalIPAddress, TD.ContentLength, TD.StatusCode, TD.LocalPort {");
67          sbuf.append("text-align: right; ");
68          sbuf.append("}");
69          sbuf.append(LINE_SEPARATOR);
70          sbuf.append("TR.header { ");
71          sbuf.append("background: #596ED5; ");
72          sbuf.append("color: #FFF; ");
73          sbuf.append("font-weight: bold; ");
74          sbuf.append("font-size: larger; ");
75          sbuf.append("}");
76          sbuf.append(LINE_SEPARATOR);
77          sbuf.append("</style>");
78      }
79  }