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.classic.html;
15  
16  
17  import ch.qos.logback.core.CoreConstants;
18  import static ch.qos.logback.core.CoreConstants.LINE_SEPARATOR;
19  import ch.qos.logback.core.html.CssBuilder;
20  
21  /**
22   * This class helps the HTMLLayout build the CSS link. It either provides the
23   * HTMLLayout with a default css file, or builds the link to an external,
24   * user-specified, file.
25   * 
26   * @author Sébastien Pennec
27   */
28  public class DefaultCssBuilder implements CssBuilder {
29  
30    public DefaultCssBuilder() {
31    }
32  
33    public void addCss(StringBuilder sbuf) {
34      sbuf.append("<style  type=\"text/css\">");
35      sbuf.append(LINE_SEPARATOR);
36      sbuf
37          .append("table { margin-left: 2em; margin-right: 2em; border-left: 2px solid #AAA; }");
38      sbuf.append(LINE_SEPARATOR);
39  
40      sbuf.append("TR.even { background: #FFFFFF; }");
41      sbuf.append(LINE_SEPARATOR);
42  
43      sbuf.append("TR.odd { background: #EAEAEA; }");
44      sbuf.append(LINE_SEPARATOR);
45  
46      sbuf
47          .append("TR.warn TD.Level, TR.error TD.Level, TR.fatal TD.Level {font-weight: bold; color: #FF4040 }");
48      sbuf.append(CoreConstants.LINE_SEPARATOR);
49  
50      sbuf
51          .append("TD { padding-right: 1ex; padding-left: 1ex; border-right: 2px solid #AAA; }");
52      sbuf.append(LINE_SEPARATOR);
53  
54      sbuf
55          .append("TD.Time, TD.Date { text-align: right; font-family: courier, monospace; font-size: smaller; }");
56      sbuf.append(LINE_SEPARATOR);
57  
58      sbuf.append("TD.Thread { text-align: left; }");
59      sbuf.append(LINE_SEPARATOR);
60  
61      sbuf.append("TD.Level { text-align: right; }");
62      sbuf.append(LINE_SEPARATOR);
63  
64      sbuf.append("TD.Logger { text-align: left; }");
65      sbuf.append(LINE_SEPARATOR);
66  
67      sbuf
68          .append("TR.header { background: #596ED5; color: #FFF; font-weight: bold; font-size: larger; }");
69      sbuf.append(CoreConstants.LINE_SEPARATOR);
70  
71      sbuf
72          .append("TD.Exception { background: #A2AEE8; font-family: courier, monospace;}");
73      sbuf.append(LINE_SEPARATOR);
74  
75      sbuf.append("</style>");
76      sbuf.append(LINE_SEPARATOR);
77    }
78  }