logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1521684 - /logging/log4j/log4j2/trunk/log4j-slf4j-impl/src/main/java/org/slf4j/helpers/EventDataConverter.java
Date Tue, 10 Sep 2013 23:48:13 GMT
Author: ggregory
Date: Tue Sep 10 23:48:13 2013
New Revision: 1521684

URL: http://svn.apache.org/r1521684
Log:
Rewrite method to avoid type casting. Also reuse key local var instead of calling getKey()
again.

Modified:
    logging/log4j/log4j2/trunk/log4j-slf4j-impl/src/main/java/org/slf4j/helpers/EventDataConverter.java

Modified: logging/log4j/log4j2/trunk/log4j-slf4j-impl/src/main/java/org/slf4j/helpers/EventDataConverter.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-slf4j-impl/src/main/java/org/slf4j/helpers/EventDataConverter.java?rev=1521684&r1=1521683&r2=1521684&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-slf4j-impl/src/main/java/org/slf4j/helpers/EventDataConverter.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-slf4j-impl/src/main/java/org/slf4j/helpers/EventDataConverter.java
Tue Sep 10 23:48:13 2013
@@ -16,35 +16,35 @@
  */
 package org.slf4j.helpers;
 
+import java.util.Map;
+
 import org.apache.logging.log4j.message.Message;
 import org.apache.logging.log4j.message.ParameterizedMessage;
 import org.apache.logging.log4j.message.StructuredDataMessage;
 import org.slf4j.ext.EventData;
 
-import java.util.Map;
-
 /**
  *
  */
 public class EventDataConverter {
 
     public Message convertEvent(final String message, final Object[] objects, final Throwable
throwable) {
-        Message msg;
         try {
-            final EventData data = (objects != null && objects[0] instanceof EventData)
? (EventData) objects[0] :
-                new EventData(message);
-            msg = new StructuredDataMessage(data.getEventId(), data.getMessage(), data.getEventType());
+            final EventData data = (objects != null && objects[0] instanceof EventData)
? (EventData) objects[0]
+                    : new EventData(message);
+            final StructuredDataMessage msg = new StructuredDataMessage(data.getEventId(),
data.getMessage(),
+                    data.getEventType());
             for (final Map.Entry<String, Object> entry : data.getEventMap().entrySet())
{
                 final String key = entry.getKey();
-                if (EventData.EVENT_TYPE.equals(key) || EventData.EVENT_ID.equals(key) ||
-                    EventData.EVENT_MESSAGE.equals(key)) {
+                if (EventData.EVENT_TYPE.equals(key) || EventData.EVENT_ID.equals(key)
+                        || EventData.EVENT_MESSAGE.equals(key)) {
                     continue;
                 }
-                ((StructuredDataMessage) msg).put(entry.getKey(), String.valueOf(entry.getValue()));
+                msg.put(key, String.valueOf(entry.getValue()));
             }
+            return msg;
         } catch (final Exception ex) {
-            msg = new ParameterizedMessage(message, objects, throwable);
+            return new ParameterizedMessage(message, objects, throwable);
         }
-        return msg;
     }
 }



Mime
View raw message