View Javadoc

1   /**
2    * Logback: the reliable, generic, fast and flexible logging framework.
3    * 
4    * Copyright (C) 1999-2006, QOS.ch
5    * 
6    * This library is free software, you can redistribute it and/or modify it under
7    * the terms of the GNU Lesser General Public License as published by the Free
8    * Software Foundation.
9    */
10  package ch.qos.logback.access.html;
11  
12  import static ch.qos.logback.core.CoreConstants.LINE_SEPARATOR;
13  import ch.qos.logback.core.html.CssBuilder;
14  
15  /**
16   * This class helps the HTMLLayout build the CSS link. It either provides the
17   * HTMLLayout with a default css file, or builds the link to an external,
18   * user-specified, file.
19   * 
20   * @author Sébastien Pennec
21   */
22  public class DefaultCssBuilder implements CssBuilder {
23  
24    public DefaultCssBuilder() {
25    }
26  
27    public void addCss(StringBuilder sbuf) {
28      sbuf.append("<style  type=\"text/css\">");
29      sbuf.append("table{ ");
30      sbuf.append("margin-left: 2em; ");
31      sbuf.append("margin-right: 2em; ");
32      sbuf.append("border-left: 2px solid #AAA; ");
33      sbuf.append("}");
34      sbuf.append(LINE_SEPARATOR);
35      sbuf.append("TR.even { ");
36      sbuf.append("background: #FFFFFF; ");
37      sbuf.append("}");
38      sbuf.append(LINE_SEPARATOR);
39      sbuf.append("TR.odd { ");
40      sbuf.append("background: #EAEAEA; ");
41      sbuf.append("}");
42      sbuf.append(LINE_SEPARATOR);
43      sbuf.append("TD {");
44      sbuf.append("padding-right: 1ex; ");
45      sbuf.append("padding-left: 1ex; ");
46      sbuf.append("border-right: 2px solid #AAA;");
47      sbuf.append("}");
48      sbuf.append(LINE_SEPARATOR);
49      sbuf.append("TD.Time, TD.Date { ");
50      sbuf.append("text-align: right; ");
51      sbuf.append("font-family: courier, monospace; ");
52      sbuf.append("font-size: smaller; ");
53      sbuf.append("}");
54      sbuf.append(LINE_SEPARATOR);
55      sbuf
56          .append("TD.RemoteHost, TD.RequestProtocol, TD.RequestHeader, TD.RequestURL, TD.RemoteUser, TD.RequestURI, TD.ServerName {");
57      sbuf.append("text-align: left; ");
58      sbuf.append("}");
59      sbuf.append(LINE_SEPARATOR);
60      sbuf
61          .append("TD.RequestAttribute, TD.RequestCookie, TD.ResponseHeader, TD.RequestParameter {");
62      sbuf.append("text-align: left; ");
63      sbuf.append("}");
64      sbuf.append(LINE_SEPARATOR);
65      sbuf
66          .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  }