You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by rp...@apache.org on 2016/04/22 07:58:44 UTC

[10/15] logging-log4j2 git commit: LOG4J2-1342 added implementation of new method #memento(), ensure internal parameters field is not null

LOG4J2-1342 added implementation of new method #memento(), ensure internal parameters field is not null


Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/ba8d2905
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/ba8d2905
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/ba8d2905

Branch: refs/heads/master
Commit: ba8d2905afaaa9355c9f20afd36d2169a9f25db9
Parents: f34a555
Author: rpopma <rp...@apache.org>
Authored: Fri Apr 22 14:38:04 2016 +0900
Committer: rpopma <rp...@apache.org>
Committed: Fri Apr 22 14:38:04 2016 +0900

----------------------------------------------------------------------
 .../logging/log4j/core/impl/MutableLogEvent.java     | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ba8d2905/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/MutableLogEvent.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/MutableLogEvent.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/MutableLogEvent.java
index e256723..7fd31c0 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/MutableLogEvent.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/MutableLogEvent.java
@@ -27,6 +27,7 @@ import org.apache.logging.log4j.ThreadContext;
 import org.apache.logging.log4j.core.LogEvent;
 import org.apache.logging.log4j.core.util.Constants;
 import org.apache.logging.log4j.message.Message;
+import org.apache.logging.log4j.message.ParameterizedMessage;
 import org.apache.logging.log4j.message.ReusableMessage;
 import org.apache.logging.log4j.message.SimpleMessage;
 import org.apache.logging.log4j.util.Strings;
@@ -60,10 +61,11 @@ public class MutableLogEvent implements LogEvent, ReusableMessage {
     private ThreadContext.ContextStack contextStack;
 
     public MutableLogEvent() {
-        this(null);
+        this(new StringBuilder(Constants.INITIAL_REUSABLE_MESSAGE_SIZE), new Object[10]);
     }
 
-    public MutableLogEvent(final Object[] replacementParameters) {
+    public MutableLogEvent(final StringBuilder msgText, final Object[] replacementParameters) {
+        this.messageText = msgText;
         this.parameters = replacementParameters;
     }
 
@@ -273,6 +275,15 @@ public class MutableLogEvent implements LogEvent, ReusableMessage {
     }
 
     @Override
+    public Message memento() {
+        if (message != null) {
+            return message;
+        }
+        Object[] params = parameters == null ? new Object[0] : Arrays.copyOf(parameters, parameterCount);
+        return new ParameterizedMessage(messageText.toString(), params);
+    }
+
+    @Override
     public Throwable getThrown() {
         return thrown;
     }