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.core;
15  
16  import ch.qos.logback.core.spi.ContextAware;
17  import ch.qos.logback.core.spi.LifeCycle;
18  
19  public interface Layout<E> extends ContextAware, LifeCycle {
20  
21      /**
22       * Transform an event (of type Object) and return it as a String after
23       * appropriate formatting.
24       * 
25       * <p>
26       * Taking in an object and returning a String is the least sophisticated way of
27       * formatting events. However, it is remarkably CPU-effective.
28       * </p>
29       * 
30       * @param event The event to format
31       * @return the event formatted as a String
32       */
33      String doLayout(E event);
34  
35      /**
36       * Return the file header for this layout. The returned value may be null.
37       * 
38       * @return The header.
39       */
40      String getFileHeader();
41  
42      /**
43       * Return the header of the logging event formatting. The returned value may be
44       * null.
45       * 
46       * @return The header.
47       */
48      String getPresentationHeader();
49  
50      /**
51       * Return the footer of the logging event formatting. The returned value may be
52       * null.
53       * 
54       * @return The footer.
55       */
56  
57      String getPresentationFooter();
58  
59      /**
60       * Return the file footer for this layout. The returned value may be null.
61       * 
62       * @return The footer.
63       */
64      String getFileFooter();
65  
66      /**
67       * Returns the content type as appropriate for the implementation.
68       * 
69       * @return
70       */
71      String getContentType();
72  
73  }