View Javadoc

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