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