[logback-dev] svn commit: r950 - in logback/trunk: logback-classic/src/test/java/ch/qos/logback/classic/html logback-classic/src/test/java/ch/qos/logback/classic/net logback-core/src/main/java/ch/qos/logback/core logback-core/src/main/java/ch/qos/logback/core/html logback-core/src/main/java/ch/qos/logback/core/net logback-core/src/test/java/ch/qos/logback/core/appender

noreply.seb at qos.ch noreply.seb at qos.ch
Fri Nov 17 17:46:14 CET 2006


Author: seb
Date: Fri Nov 17 17:46:14 2006
New Revision: 950

Modified:
   logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/html/HTMLLayoutTest.java
   logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SMTPAppenderTest.java
   logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SMTPAppenderTestApp.java
   logback/trunk/logback-core/src/main/java/ch/qos/logback/core/Layout.java
   logback/trunk/logback-core/src/main/java/ch/qos/logback/core/LayoutBase.java
   logback/trunk/logback-core/src/main/java/ch/qos/logback/core/WriterAppender.java
   logback/trunk/logback-core/src/main/java/ch/qos/logback/core/html/HTMLLayoutBase.java
   logback/trunk/logback-core/src/main/java/ch/qos/logback/core/net/SMTPAppenderBase.java
   logback/trunk/logback-core/src/test/java/ch/qos/logback/core/appender/ConsoleAppenderTest.java

Log:
Added PresentationHeader and PresentationFooter to Layout interface
Modified Header and Footer attributes to FileHeader and FileFooter
Updated layouts and tests accordingly

Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/html/HTMLLayoutTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/html/HTMLLayoutTest.java	(original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/html/HTMLLayoutTest.java	Fri Nov 17 17:46:14 2006
@@ -55,7 +55,7 @@
 
   @SuppressWarnings("unchecked")
   public void testHeader() {
-    String header = layout.getHeader();
+    String header = layout.getFileHeader();
     //System.out.println(header);
 
     Document doc = parseOutput(header + "</table></body></html>");
@@ -110,7 +110,7 @@
         "test Exception")));
     String result = layout.doLayout(le);
 
-    String stringToParse = layout.getHeader();
+    String stringToParse = layout.getFileHeader();
     stringToParse += result;
     stringToParse += "</table></body></html>";
 

Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SMTPAppenderTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SMTPAppenderTest.java	(original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SMTPAppenderTest.java	Fri Nov 17 17:46:14 2006
@@ -89,9 +89,9 @@
   private static Layout buildLayout(LoggerContext lc) {
     PatternLayout layout = new PatternLayout();
     layout.setContext(lc);
-    layout.setHeader("Some header\n");
+    layout.setFileHeader("Some header\n");
     layout.setPattern("%-4relative [%thread] %-5level %class - %msg%n");
-    layout.setFooter("Some footer");
+    layout.setFileFooter("Some footer");
     layout.start();
     return layout;
   }

Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SMTPAppenderTestApp.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SMTPAppenderTestApp.java	(original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SMTPAppenderTestApp.java	Fri Nov 17 17:46:14 2006
@@ -41,9 +41,9 @@
   private static Layout buildLayout(LoggerContext lc) {
     PatternLayout layout = new PatternLayout();
     layout.setContext(lc);
-    layout.setHeader("Some header\n");
+    layout.setFileHeader("Some header\n");
     layout.setPattern("%-4relative [%thread] %-5level %class - %msg %X{test}%n");
-    layout.setFooter("Some footer");
+    layout.setFileFooter("Some footer");
     layout.start();
     return layout;
   }

Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/Layout.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/Layout.java	(original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/Layout.java	Fri Nov 17 17:46:14 2006
@@ -31,16 +31,33 @@
   String doLayout(Object event);
   
   /**
-   * Return the header for this layout. The returned value may be null.
+   * Return the file header for this layout. The returned value may be null.
    * @return The header.
    */
-  String getHeader();
+  String getFileHeader();
 
   /**
-   * Return the footer for this layout. The returned value may be null.
+   * Return the header of the logging event formatting. The returned value
+   * may be null.
+   * 
+   * @return The header.
+   */
+  String getPresentationHeader();
+
+  /**
+   * Return the footer of the logging event formatting. The returned value
+   * may be null.
+   * 
+   * @return The footer.
+   */
+  
+  String getPresentationFooter();
+  
+  /**
+   * Return the file footer for this layout. The returned value may be null.
    * @return The footer.
    */
-  String getFooter();
+  String getFileFooter();
   
   /**
    * Returns the content type as appropriate for the implementation.

Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/LayoutBase.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/LayoutBase.java	(original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/LayoutBase.java	Fri Nov 17 17:46:14 2006
@@ -16,8 +16,10 @@
   Context context;
   protected boolean started;
   
-  String header;
-  String footer;
+  String fileHeader;
+  String fileFooter;
+  String presentationHeader;
+  String presentationFooter;
   
   public void setContext(Context context) {
     this.context = context;
@@ -39,23 +41,39 @@
     return started;
   }
   
-  public String getHeader() {
-    return header;
+  public String getFileHeader() {
+    return fileHeader;
   }
   
-  public String getFooter() {
-    return footer;
+  public String getPresentationHeader() {
+    return presentationHeader;
+  }
+  
+  public String getPresentationFooter() {
+    return presentationFooter;
+  }
+  
+  public String getFileFooter() {
+    return fileFooter;
   }
 
   public String getContentType() {
     return "text/plain";
   }
   
-  public void setHeader(String header) {
-    this.header = header;
+  public void setFileHeader(String header) {
+    this.fileHeader = header;
+  }
+
+  public void setFileFooter(String footer) {
+    this.fileFooter = footer;
+  }
+  
+  public void setPresentationHeader(String header) {
+    this.presentationHeader = header;
   }
 
-  public void setFooter(String footer) {
-    this.footer = footer;
+  public void setPresentationFooter(String footer) {
+    this.presentationFooter = footer;
   }
 }

Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/WriterAppender.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/WriterAppender.java	(original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/WriterAppender.java	Fri Nov 17 17:46:14 2006
@@ -205,7 +205,7 @@
 
   void writeHeader() {
     if (layout != null) {
-      String h = layout.getHeader();
+      String h = layout.getFileHeader();
 
       if ((h != null) && (this.writer != null)) {
         try {
@@ -226,7 +226,7 @@
 
   void writeFooter() {
     if (layout != null) {
-      String h = layout.getFooter();
+      String h = layout.getFileFooter();
       if ((h != null) && (this.writer != null)) {
         try {
           this.writer.write(h);

Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/html/HTMLLayoutBase.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/html/HTMLLayoutBase.java	(original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/html/HTMLLayoutBase.java	Fri Nov 17 17:46:14 2006
@@ -119,7 +119,7 @@
    * Returns appropriate HTML headers.
    */
   @Override
-  public String getHeader() {
+  public String getFileHeader() {
     StringBuffer sbuf = new StringBuffer();
     sbuf.append("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"");
     sbuf.append(" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">");
@@ -190,7 +190,7 @@
    * Returns the appropriate HTML footers.
    */
   @Override
-  public String getFooter() {
+  public String getFileFooter() {
     StringBuffer sbuf = new StringBuffer();
     sbuf.append("</table>");
     sbuf.append(LINE_SEP);

Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/net/SMTPAppenderBase.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/net/SMTPAppenderBase.java	(original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/net/SMTPAppenderBase.java	Fri Nov 17 17:46:14 2006
@@ -184,12 +184,12 @@
 
       StringBuffer sbuf = new StringBuffer();
       
-      String header = layout.getHeader();
+      String header = layout.getFileHeader();
       if (header != null) {
         sbuf.append(header);
       }
       fillBuffer(sbuf);
-      String footer = layout.getFooter();
+      String footer = layout.getFileFooter();
       if (footer != null) {
         sbuf.append(footer);
       }

Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/appender/ConsoleAppenderTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/appender/ConsoleAppenderTest.java	(original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/appender/ConsoleAppenderTest.java	Fri Nov 17 17:46:14 2006
@@ -70,7 +70,7 @@
   public void testOpen() {
     ConsoleAppender ca = (ConsoleAppender) getAppender();
     DummyLayout dummyLayout = new DummyLayout();
-    dummyLayout.setHeader("open");
+    dummyLayout.setFileHeader("open");
     ca.setLayout(dummyLayout);
     ca.start();
     ca.doAppend(new Object());
@@ -80,7 +80,7 @@
   public void testClose() {
     ConsoleAppender ca = (ConsoleAppender) getAppender();
     DummyLayout dummyLayout = new DummyLayout();
-    dummyLayout.setFooter("closed");
+    dummyLayout.setFileFooter("closed");
     ca.setLayout(dummyLayout);
     ca.start();
     ca.doAppend(new Object());



More information about the logback-dev mailing list