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