logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgo...@apache.org
Subject svn commit: r1186227 - in /logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers: log4j12-api/src/test/java/org/apache/log4j/ log4j2-api/src/main/java/org/apache/logging/log4j/ log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/ log4j2-cor...
Date Wed, 19 Oct 2011 14:04:04 GMT
Author: rgoers
Date: Wed Oct 19 14:04:03 2011
New Revision: 1186227

URL: http://svn.apache.org/viewvc?rev=1186227&view=rev
Log:
Fix compile error in CategoryTest. Add MarkerPatternConverter (still needs tests)

Added:
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/MarkerPatternConverter.java
      - copied, changed from r1185987, logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/MessagePatternConverter.java
Modified:
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j12-api/src/test/java/org/apache/log4j/CategoryTest.java
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/MarkerManager.java
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/pattern/PatternParserTest.java

Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j12-api/src/test/java/org/apache/log4j/CategoryTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j12-api/src/test/java/org/apache/log4j/CategoryTest.java?rev=1186227&r1=1186226&r2=1186227&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j12-api/src/test/java/org/apache/log4j/CategoryTest.java
(original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j12-api/src/test/java/org/apache/log4j/CategoryTest.java
Wed Oct 19 14:04:03 2011
@@ -143,7 +143,7 @@ public class CategoryTest {
     @Test
     public void testClassName() {
         Category category = Category.getInstance("TestCategory");
-        Layout layout = PatternLayout.createLayout("%d %p %C{1.} [%t] %m%n", null);
+        Layout layout = PatternLayout.createLayout("%d %p %C{1.} [%t] %m%n", null, null,
null);
         ListAppender appender = new ListAppender("List2", null, layout, false, false);
         appender.start();
         category.setAdditivity(false);

Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/MarkerManager.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/MarkerManager.java?rev=1186227&r1=1186226&r2=1186227&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/MarkerManager.java
(original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/MarkerManager.java
Wed Oct 19 14:04:03 2011
@@ -130,5 +130,24 @@ public final class MarkerManager {
         public int hashCode() {
             return name != null ? name.hashCode() : 0;
         }
+
+        public String toString() {
+            StringBuilder sb = new StringBuilder(name);
+            if (parent != null) {
+                Marker m = parent;
+                sb.append("[ ");
+                boolean first = true;
+                while (m != null) {
+                    if (!first) {
+                        sb.append(", ");
+                    }
+                    sb.append(m.getName());
+                    first = false;
+                    m = m.getParent();
+                }
+                sb.append(" ]");
+            }
+            return sb.toString();
+        }
     }
 }

Copied: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/MarkerPatternConverter.java
(from r1185987, logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/MessagePatternConverter.java)
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/MarkerPatternConverter.java?p2=logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/MarkerPatternConverter.java&p1=logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/MessagePatternConverter.java&r1=1185987&r2=1186227&rev=1186227&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/MessagePatternConverter.java
(original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/MarkerPatternConverter.java
Wed Oct 19 14:04:03 2011
@@ -17,6 +17,7 @@
 
 package org.apache.logging.log4j.core.pattern;
 
+import org.apache.logging.log4j.Marker;
 import org.apache.logging.log4j.core.LogEvent;
 import org.apache.logging.log4j.core.config.plugins.Plugin;
 import org.apache.logging.log4j.message.FormattedMessage;
@@ -26,9 +27,9 @@ import org.apache.logging.log4j.message.
 /**
  * Return the event's rendered message in a StringBuffer.
  */
-@Plugin(name="MessagePatternConverter", type="Converter")
-@ConverterKeys({"m", "msg", "message"})
-public final class MessagePatternConverter extends LogEventPatternConverter {
+@Plugin(name="MarkerPatternConverter", type="Converter")
+@ConverterKeys({"marker"})
+public final class MarkerPatternConverter extends LogEventPatternConverter {
 
     private final String format;
 
@@ -36,8 +37,8 @@ public final class MessagePatternConvert
      * Private constructor.
      * @param options options, may be null.
      */
-    private MessagePatternConverter(final String[] options) {
-        super("Message", "message");
+    private MarkerPatternConverter(final String[] options) {
+        super("Marker", "marker");
         format = (options != null && options.length > 0) ? options[0] : null;
     }
 
@@ -47,18 +48,17 @@ public final class MessagePatternConvert
      * @param options options, may be null.
      * @return instance of pattern converter.
      */
-    public static MessagePatternConverter newInstance(final String[] options) {
-        return new MessagePatternConverter(options);
+    public static MarkerPatternConverter newInstance(final String[] options) {
+        return new MarkerPatternConverter(options);
     }
 
     /**
      * {@inheritDoc}
      */
     public void format(final LogEvent event, final StringBuilder toAppendTo) {
-        Message msg = event.getMessage();
-        if (msg != null && msg instanceof FormattedMessage) {
-            ((FormattedMessage) msg).setFormat(format);
+        Marker marker = event.getMarker();
+        if (marker != null) {
+            toAppendTo.append(marker.toString());
         }
-        toAppendTo.append(msg.getFormattedMessage());
     }
 }

Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/pattern/PatternParserTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/pattern/PatternParserTest.java?rev=1186227&r1=1186226&r2=1186227&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/pattern/PatternParserTest.java
(original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/pattern/PatternParserTest.java
Wed Oct 19 14:04:03 2011
@@ -74,5 +74,4 @@ public class PatternParserTest {
         validateConverter(converters, 1, "Line Sep");
     }
 
-
 }



Mime
View raw message