logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgo...@apache.org
Subject svn commit: r1396490 - in /logging/log4j/log4j2/trunk: core/src/main/java/org/apache/logging/log4j/core/ core/src/main/java/org/apache/logging/log4j/core/appender/ core/src/main/java/org/apache/logging/log4j/core/layout/ core/src/test/java/org/apache/l...
Date Wed, 10 Oct 2012 07:07:29 GMT
Author: rgoers
Date: Wed Oct 10 07:07:28 2012
New Revision: 1396490

URL: http://svn.apache.org/viewvc?rev=1396490&view=rev
Log:
Rename format and formatAs to toByteArray and toSerialized

Modified:
    logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/Layout.java
    logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/JMSQueueAppender.java
    logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/JMSTopicAppender.java
    logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/OutputStreamAppender.java
    logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/layout/AbstractStringLayout.java
    logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/layout/HTMLLayout.java
    logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/layout/PatternLayout.java
    logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/layout/RFC5424Layout.java
    logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/layout/SerializedLayout.java
    logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/layout/SyslogLayout.java
    logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/layout/XMLLayout.java
    logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/layout/PatternLayoutTest.java
    logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/test/appender/ListAppender.java
    logging/log4j/log4j2/trunk/flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumeAppender.java

Modified: logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/Layout.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/Layout.java?rev=1396490&r1=1396489&r2=1396490&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/Layout.java
(original)
+++ logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/Layout.java
Wed Oct 10 07:07:28 2012
@@ -28,20 +28,22 @@ import java.io.Serializable;
 public interface Layout<T extends Serializable> {
     /**
      * Formats the event suitable for display.
+     *
      * @param event The Logging Event.
      * @return The formatted event.
      * @doubt Likely better to write to a OutputStream instead of return a byte[]. (RG) That
limits how the
      * Appender can use the Layout. For example, it might concatenate information in front
or behind the
      * data and then write it all to the OutputStream in one call.
      */
-    byte[] format(LogEvent event);
+    byte[] toByteArray(LogEvent event);
 
     /**
      * Formats the event as an Object that can be serialized.
+     *
      * @param event The Logging Event.
      * @return The formatted event.
      */
-    T formatAs(LogEvent event);
+    T toSerialized(LogEvent event);
 
     /**
      * Returns the header for the layout format.

Modified: logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/JMSQueueAppender.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/JMSQueueAppender.java?rev=1396490&r1=1396489&r2=1396490&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/JMSQueueAppender.java
(original)
+++ logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/JMSQueueAppender.java
Wed Oct 10 07:07:28 2012
@@ -47,7 +47,7 @@ public final class JMSQueueAppender exte
      */
     public void append(LogEvent event) {
         try {
-            manager.send(getLayout().formatAs(event));
+            manager.send(getLayout().toSerialized(event));
         } catch (Exception ex) {
             throw new AppenderRuntimeException(ex);
         }

Modified: logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/JMSTopicAppender.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/JMSTopicAppender.java?rev=1396490&r1=1396489&r2=1396490&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/JMSTopicAppender.java
(original)
+++ logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/JMSTopicAppender.java
Wed Oct 10 07:07:28 2012
@@ -47,7 +47,7 @@ public final class JMSTopicAppender exte
      */
     public void append(LogEvent event) {
         try {
-            manager.send(getLayout().formatAs(event));
+            manager.send(getLayout().toSerialized(event));
         } catch (Exception ex) {
             throw new AppenderRuntimeException(ex);
         }

Modified: logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/OutputStreamAppender.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/OutputStreamAppender.java?rev=1396490&r1=1396489&r2=1396490&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/OutputStreamAppender.java
(original)
+++ logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/OutputStreamAppender.java
Wed Oct 10 07:07:28 2012
@@ -109,7 +109,7 @@ public abstract class OutputStreamAppend
     public void append(LogEvent event) {
         readLock.lock();
         try {
-            manager.write(getLayout().format(event));
+            manager.write(getLayout().toByteArray(event));
             if (this.immediateFlush) {
                 manager.flush();
             }

Modified: logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/layout/AbstractStringLayout.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/layout/AbstractStringLayout.java?rev=1396490&r1=1396489&r2=1396490&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/layout/AbstractStringLayout.java
(original)
+++ logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/layout/AbstractStringLayout.java
Wed Oct 10 07:07:28 2012
@@ -50,11 +50,12 @@ public abstract class AbstractStringLayo
 
     /**
      * Format the Log Event.
+     *
      * @param event The Log Event.
      * @return The formatted event as a byte array.
      */
-    public byte[] format(LogEvent event) {
-        return encoder.getBytes(formatAs(event));
+    public byte[] toByteArray(LogEvent event) {
+        return encoder.getBytes(toSerialized(event));
     }
 
     protected Charset getCharset() {

Modified: logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/layout/HTMLLayout.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/layout/HTMLLayout.java?rev=1396490&r1=1396489&r2=1396490&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/layout/HTMLLayout.java
(original)
+++ logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/layout/HTMLLayout.java
Wed Oct 10 07:07:28 2012
@@ -70,10 +70,11 @@ public final class HTMLLayout extends Ab
 
     /**
      * Format as a String.
+     *
      * @param event The Logging Event.
      * @return A String containging the LogEvent as HTML.
      */
-    public String formatAs(LogEvent event) {
+    public String toSerialized(LogEvent event) {
         StringBuilder sbuf = new StringBuilder(BUF_SIZE);
 
         sbuf.append(LINE_SEP).append("<tr>").append(LINE_SEP);

Modified: logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/layout/PatternLayout.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/layout/PatternLayout.java?rev=1396490&r1=1396489&r2=1396490&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/layout/PatternLayout.java
(original)
+++ logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/layout/PatternLayout.java
Wed Oct 10 07:07:28 2012
@@ -34,7 +34,7 @@ import java.util.List;
 
 /**
  * <p>A flexible layout configurable with pattern string. The goal of this class
- * is to {@link #format format} a {@link LogEvent} and return the results.
+ * is to {@link org.apache.logging.log4j.core.Layout#toByteArray format} a {@link LogEvent}
and return the results.
  * The format of the result depends on the <em>conversion pattern</em>.
  * <p>
  * <p/>
@@ -131,10 +131,11 @@ public final class PatternLayout extends
     /**
      * Formats a logging event to a writer.
      *
+     *
      * @param event logging event to be formatted.
      * @return The event formatted as a String.
      */
-    public String formatAs(final LogEvent event) {
+    public String toSerialized(final LogEvent event) {
         StringBuilder buf = new StringBuilder();
         for (PatternFormatter formatter : formatters) {
             formatter.format(event, buf);

Modified: logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/layout/RFC5424Layout.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/layout/RFC5424Layout.java?rev=1396490&r1=1396489&r2=1396490&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/layout/RFC5424Layout.java
(original)
+++ logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/layout/RFC5424Layout.java
Wed Oct 10 07:07:28 2012
@@ -148,10 +148,11 @@ public final class RFC5424Layout extends
 
     /**
      * Formats a {@link org.apache.logging.log4j.core.LogEvent} in conformance with the RFC
5424 Syslog specification.
+     *
      * @param event The LogEvent.
      * @return The RFC 5424 String representation of the LogEvent.
      */
-    public String formatAs(final LogEvent event) {
+    public String toSerialized(final LogEvent event) {
         Message msg = event.getMessage();
         boolean isStructured = msg instanceof StructuredDataMessage;
         StringBuilder buf = new StringBuilder();

Modified: logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/layout/SerializedLayout.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/layout/SerializedLayout.java?rev=1396490&r1=1396489&r2=1396490&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/layout/SerializedLayout.java
(original)
+++ logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/layout/SerializedLayout.java
Wed Oct 10 07:07:28 2012
@@ -49,10 +49,11 @@ public final class SerializedLayout exte
 
     /**
      * Formats a {@link org.apache.logging.log4j.core.LogEvent} in conformance with the log4j.dtd.
+     *
      * @param event The LogEvent.
      * @return the formatted LogEvent.
      */
-    public byte[] format(final LogEvent event) {
+    public byte[] toByteArray(final LogEvent event) {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         try {
             ObjectOutputStream oos = new PrivateObjectOutputStream(baos);
@@ -65,10 +66,11 @@ public final class SerializedLayout exte
 
     /**
      * Returns the LogEvent.
+     *
      * @param event The Logging Event.
      * @return The LogEvent.
      */
-    public LogEvent formatAs(final LogEvent event) {
+    public LogEvent toSerialized(final LogEvent event) {
         return event;
     }
 

Modified: logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/layout/SyslogLayout.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/layout/SyslogLayout.java?rev=1396490&r1=1396489&r2=1396490&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/layout/SyslogLayout.java
(original)
+++ logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/layout/SyslogLayout.java
Wed Oct 10 07:07:28 2012
@@ -58,10 +58,11 @@ public class SyslogLayout extends Abstra
 
     /**
      * Formats a {@link org.apache.logging.log4j.core.LogEvent} in conformance with the log4j.dtd.
+     *
      * @param event The LogEvent
      * @return the event formatted as a String.
      */
-    public String formatAs(final LogEvent event) {
+    public String toSerialized(final LogEvent event) {
         StringBuilder buf = new StringBuilder();
 
         buf.append("<");

Modified: logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/layout/XMLLayout.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/layout/XMLLayout.java?rev=1396490&r1=1396489&r2=1396490&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/layout/XMLLayout.java
(original)
+++ logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/layout/XMLLayout.java
Wed Oct 10 07:07:28 2012
@@ -90,10 +90,11 @@ public class XMLLayout extends AbstractS
 
     /**
      * Formats a {@link org.apache.logging.log4j.core.LogEvent} in conformance with the log4j.dtd.
+     *
      * @param event The LogEvent.
      * @return The XML representation of the LogEvent.
      */
-    public String formatAs(final LogEvent event) {
+    public String toSerialized(final LogEvent event) {
         StringBuilder buf = new StringBuilder(DEFAULT_SIZE);
 
         // We yield to the \r\n heresy.

Modified: logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/layout/PatternLayoutTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/layout/PatternLayoutTest.java?rev=1396490&r1=1396489&r2=1396490&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/layout/PatternLayoutTest.java
(original)
+++ logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/layout/PatternLayoutTest.java
Wed Oct 10 07:07:28 2012
@@ -24,7 +24,6 @@ import org.apache.logging.log4j.core.Log
 import org.apache.logging.log4j.core.LoggerContext;
 import org.apache.logging.log4j.core.BasicConfigurationFactory;
 import org.apache.logging.log4j.core.appender.FileAppender;
-import org.apache.logging.log4j.core.appender.FileManager;
 import org.apache.logging.log4j.core.config.ConfigurationFactory;
 import org.apache.logging.log4j.core.impl.Log4jLogEvent;
 import org.apache.logging.log4j.core.util.Compare;
@@ -33,8 +32,6 @@ import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
-import java.io.FileOutputStream;
-
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.assertEquals;
 
@@ -143,7 +140,7 @@ public class PatternLayoutTest {
             null, null);
         LogEvent event = new Log4jLogEvent(this.getClass().getName(), null, "org.apache.logging.log4j.core.Logger",
             Level.INFO, new SimpleMessage("Hello, world!"), null);
-        byte[] result = layout.format(event);
+        byte[] result = layout.toByteArray(event);
         assertEquals("org/apache/logging/log4j/core/layout/PatternLayoutTest Hello, world!",
new String(result));
     }
 }

Modified: logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/test/appender/ListAppender.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/test/appender/ListAppender.java?rev=1396490&r1=1396489&r2=1396490&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/test/appender/ListAppender.java
(original)
+++ logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/test/appender/ListAppender.java
Wed Oct 10 07:07:28 2012
@@ -46,7 +46,7 @@ public class ListAppender extends Abstra
     private final boolean newLine;
 
     private final boolean raw;
-    
+
     private static final String WINDOWS_LINE_SEP = "\r\n";
 
     public ListAppender(String name) {
@@ -73,13 +73,13 @@ public class ListAppender extends Abstra
             events.add(event);
         } else if (layout instanceof SerializedLayout) {
             byte[] header = layout.getHeader();
-            byte[] content = layout.format(event);
+            byte[] content = layout.toByteArray(event);
             byte[] record = new byte[header.length + content.length];
             System.arraycopy(header, 0, record, 0, header.length);
             System.arraycopy(content, 0, record, header.length, content.length);
             data.add(record);
         } else {
-            write(layout.format(event));
+            write(layout.toByteArray(event));
         }
     }
 

Modified: logging/log4j/log4j2/trunk/flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumeAppender.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumeAppender.java?rev=1396490&r1=1396489&r2=1396490&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumeAppender.java
(original)
+++ logging/log4j/log4j2/trunk/flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumeAppender.java
Wed Oct 10 07:07:28 2012
@@ -76,7 +76,7 @@ public final class FlumeAppender extends
 
         FlumeEvent flumeEvent = factory.createEvent(event, mdcIncludes, mdcExcludes, mdcRequired,
mdcPrefix,
             eventPrefix, compressBody);
-        flumeEvent.setBody(getLayout().format(flumeEvent));
+        flumeEvent.setBody(getLayout().toByteArray(flumeEvent));
         manager.send(flumeEvent, reconnectDelay, retries);
     }
 



Mime
View raw message