001/** 002 * Logback: the reliable, generic, fast and flexible logging framework. 003 * Copyright (C) 1999-2015, QOS.ch. All rights reserved. 004 * 005 * This program and the accompanying materials are dual-licensed under 006 * either the terms of the Eclipse Public License v1.0 as published by 007 * the Eclipse Foundation 008 * 009 * or (per the licensee's choosing) 010 * 011 * under the terms of the GNU Lesser General Public License version 2.1 012 * as published by the Free Software Foundation. 013 */ 014package ch.qos.logback.core; 015 016import ch.qos.logback.core.spi.ContextAware; 017import ch.qos.logback.core.spi.LifeCycle; 018 019public interface Layout<E> extends ContextAware, LifeCycle { 020 021 /** 022 * Transform an event (of type Object) and return it as a String after 023 * appropriate formatting. 024 * 025 * <p> 026 * Taking in an object and returning a String is the least sophisticated way of 027 * formatting events. However, it is remarkably CPU-effective. 028 * </p> 029 * 030 * @param event The event to format 031 * @return the event formatted as a String 032 */ 033 String doLayout(E event); 034 035 /** 036 * Return the file header for this layout. The returned value may be null. 037 * 038 * @return The header. 039 */ 040 String getFileHeader(); 041 042 /** 043 * Return the header of the logging event formatting. The returned value may be 044 * null. 045 * 046 * @return The header. 047 */ 048 String getPresentationHeader(); 049 050 /** 051 * Return the footer of the logging event formatting. The returned value may be 052 * null. 053 * 054 * @return The footer. 055 */ 056 057 String getPresentationFooter(); 058 059 /** 060 * Return the file footer for this layout. The returned value may be null. 061 * 062 * @return The footer. 063 */ 064 String getFileFooter(); 065 066 /** 067 * Returns the content type as appropriate for the implementation. 068 * 069 * @return 070 */ 071 String getContentType(); 072 073}