Blame SOURCES/logging-log4j-Remove-unsupported-EventDataConverter.patch

a58c5e
diff --git a/log4j-slf4j-impl/src/main/java/org/apache/logging/slf4j/EventDataConverter.java b/log4j-slf4j-impl/src/main/java/org/apache/logging/slf4j/EventDataConverter.java
a58c5e
deleted file mode 100644
a58c5e
index 620232a..0000000
a58c5e
--- a/log4j-slf4j-impl/src/main/java/org/apache/logging/slf4j/EventDataConverter.java
a58c5e
+++ /dev/null
a58c5e
@@ -1,50 +0,0 @@
a58c5e
-/*
a58c5e
- * Licensed to the Apache Software Foundation (ASF) under one or more
a58c5e
- * contributor license agreements. See the NOTICE file distributed with
a58c5e
- * this work for additional information regarding copyright ownership.
a58c5e
- * The ASF licenses this file to You under the Apache license, Version 2.0
a58c5e
- * (the "License"); you may not use this file except in compliance with
a58c5e
- * the License. You may obtain a copy of the License at
a58c5e
- *
a58c5e
- *      http://www.apache.org/licenses/LICENSE-2.0
a58c5e
- *
a58c5e
- * Unless required by applicable law or agreed to in writing, software
a58c5e
- * distributed under the License is distributed on an "AS IS" BASIS,
a58c5e
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
a58c5e
- * See the license for the specific language governing permissions and
a58c5e
- * limitations under the license.
a58c5e
- */
a58c5e
-package org.apache.logging.slf4j;
a58c5e
-
a58c5e
-import java.util.Map;
a58c5e
-
a58c5e
-import org.apache.logging.log4j.message.Message;
a58c5e
-import org.apache.logging.log4j.message.ParameterizedMessage;
a58c5e
-import org.apache.logging.log4j.message.StructuredDataMessage;
a58c5e
-import org.slf4j.ext.EventData;
a58c5e
-
a58c5e
-/**
a58c5e
- *
a58c5e
- */
a58c5e
-public class EventDataConverter {
a58c5e
-
a58c5e
-    public Message convertEvent(final String message, final Object[] objects, final Throwable throwable) {
a58c5e
-        try {
a58c5e
-            final EventData data = objects != null && objects[0] instanceof EventData ?
a58c5e
-                    (EventData) objects[0] : new EventData(message);
a58c5e
-            final StructuredDataMessage msg =
a58c5e
-                    new StructuredDataMessage(data.getEventId(), data.getMessage(), data.getEventType());
a58c5e
-            for (final Map.Entry<String, Object> entry : data.getEventMap().entrySet()) {
a58c5e
-                final String key = entry.getKey();
a58c5e
-                if (EventData.EVENT_TYPE.equals(key) || EventData.EVENT_ID.equals(key)
a58c5e
-                        || EventData.EVENT_MESSAGE.equals(key)) {
a58c5e
-                    continue;
a58c5e
-                }
a58c5e
-                msg.put(key, String.valueOf(entry.getValue()));
a58c5e
-            }
a58c5e
-            return msg;
a58c5e
-        } catch (final Exception ex) {
a58c5e
-            return new ParameterizedMessage(message, objects, throwable);
a58c5e
-        }
a58c5e
-    }
a58c5e
-}
a58c5e
diff --git a/log4j-slf4j-impl/src/main/java/org/apache/logging/slf4j/Log4jLogger.java b/log4j-slf4j-impl/src/main/java/org/apache/logging/slf4j/Log4jLogger.java
a58c5e
index 1fa8080..90cfe4e 100644
a58c5e
--- a/log4j-slf4j-impl/src/main/java/org/apache/logging/slf4j/Log4jLogger.java
a58c5e
+++ b/log4j-slf4j-impl/src/main/java/org/apache/logging/slf4j/Log4jLogger.java
a58c5e
@@ -27,9 +27,7 @@ import org.apache.logging.log4j.message.Message;
a58c5e
 import org.apache.logging.log4j.message.ParameterizedMessage;
a58c5e
 import org.apache.logging.log4j.message.SimpleMessage;
a58c5e
 import org.apache.logging.log4j.spi.ExtendedLogger;
a58c5e
-import org.apache.logging.log4j.util.LoaderUtil;
a58c5e
 import org.slf4j.Marker;
a58c5e
-import org.slf4j.MarkerFactory;
a58c5e
 import org.slf4j.impl.StaticMarkerBinder;
a58c5e
 import org.slf4j.spi.LocationAwareLogger;
a58c5e
 
a58c5e
@@ -39,18 +37,13 @@ import org.slf4j.spi.LocationAwareLogger;
a58c5e
 public class Log4jLogger implements LocationAwareLogger, Serializable {
a58c5e
 
a58c5e
     public static final String FQCN = Log4jLogger.class.getName();
a58c5e
-
a58c5e
     private static final long serialVersionUID = 7869000638091304316L;
a58c5e
-    private static final Marker EVENT_MARKER = MarkerFactory.getMarker("EVENT");
a58c5e
-    private static final EventDataConverter CONVERTER = createConverter();
a58c5e
 
a58c5e
-    private final boolean eventLogger;
a58c5e
     private transient ExtendedLogger logger;
a58c5e
     private final String name;
a58c5e
 
a58c5e
     public Log4jLogger(final ExtendedLogger logger, final String name) {
a58c5e
         this.logger = logger;
a58c5e
-        this.eventLogger = "EventLogger".equals(name);
a58c5e
         this.name = name;
a58c5e
     }
a58c5e
 
a58c5e
@@ -363,9 +356,7 @@ public class Log4jLogger implements LocationAwareLogger, Serializable {
a58c5e
             return;
a58c5e
         }
a58c5e
         final Message msg;
a58c5e
-        if (CONVERTER != null && eventLogger && marker != null && marker.contains(EVENT_MARKER)) {
a58c5e
-            msg = CONVERTER.convertEvent(message, params, throwable);
a58c5e
-        } else if (params == null) {
a58c5e
+        if (params == null) {
a58c5e
             msg = new SimpleMessage(message);
a58c5e
         } else {
a58c5e
             msg = new ParameterizedMessage(message, params, throwable);
a58c5e
@@ -410,15 +401,6 @@ public class Log4jLogger implements LocationAwareLogger, Serializable {
a58c5e
         aOutputStream.defaultWriteObject();
a58c5e
     }
a58c5e
 
a58c5e
-    private static EventDataConverter createConverter() {
a58c5e
-        try {
a58c5e
-            LoaderUtil.loadClass("org.slf4j.ext.EventData");
a58c5e
-            return new EventDataConverter();
a58c5e
-        } catch (final ClassNotFoundException cnfe) {
a58c5e
-            return null;
a58c5e
-        }
a58c5e
-    }
a58c5e
-
a58c5e
     private static Level getLevel(final int i) {
a58c5e
         switch (i) {
a58c5e
         case TRACE_INT:
a58c5e
diff --git a/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/LoggerTest.java b/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/LoggerTest.java
a58c5e
index 0524074..c60f1ad 100644
a58c5e
--- a/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/LoggerTest.java
a58c5e
+++ b/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/LoggerTest.java
a58c5e
@@ -21,7 +21,6 @@ import static org.junit.Assert.assertNotNull;
a58c5e
 import static org.junit.Assert.assertTrue;
a58c5e
 
a58c5e
 import java.util.List;
a58c5e
-import java.util.Locale;
a58c5e
 
a58c5e
 import org.apache.logging.log4j.junit.LoggerContextRule;
a58c5e
 import org.apache.logging.log4j.test.appender.ListAppender;
a58c5e
@@ -34,8 +33,6 @@ import org.slf4j.Logger;
a58c5e
 import org.slf4j.LoggerFactory;
a58c5e
 import org.slf4j.MDC;
a58c5e
 import org.slf4j.Marker;
a58c5e
-import org.slf4j.ext.EventData;
a58c5e
-import org.slf4j.ext.EventLogger;
a58c5e
 import org.slf4j.ext.XLogger;
a58c5e
 import org.slf4j.ext.XLoggerFactory;
a58c5e
 import org.slf4j.spi.LocationAwareLogger;
a58c5e
@@ -145,23 +142,6 @@ public class LoggerTest {
a58c5e
         verify("List", "o.a.l.s.LoggerTest Hello, Log4j Log4j {} MDC{}" + Strings.LINE_SEPARATOR);
a58c5e
     }
a58c5e
 
a58c5e
-    @Test
a58c5e
-    public void testEventLogger() {
a58c5e
-        MDC.put("loginId", "JohnDoe");
a58c5e
-        MDC.put("ipAddress", "192.168.0.120");
a58c5e
-        MDC.put("locale", Locale.US.getDisplayName());
a58c5e
-        final EventData data = new EventData();
a58c5e
-        data.setEventType("Transfer");
a58c5e
-        data.setEventId("Audit@18060");
a58c5e
-        data.setMessage("Transfer Complete");
a58c5e
-        data.put("ToAccount", "123456");
a58c5e
-        data.put("FromAccount", "123457");
a58c5e
-        data.put("Amount", "200.00");
a58c5e
-        EventLogger.logEvent(data);
a58c5e
-        MDC.clear();
a58c5e
-        verify("EventLogger", "o.a.l.s.LoggerTest Transfer [Audit@18060 Amount=\"200.00\" FromAccount=\"123457\" ToAccount=\"123456\"] Transfer Complete" + Strings.LINE_SEPARATOR);
a58c5e
-    }
a58c5e
-
a58c5e
     private void verify(final String name, final String expected) {
a58c5e
         final ListAppender listApp = ctx.getListAppender(name);
a58c5e
         assertNotNull("Missing Appender", listApp);
a58c5e
@@ -177,6 +157,5 @@ public class LoggerTest {
a58c5e
     public void cleanup() {
a58c5e
         MDC.clear();
a58c5e
         ctx.getListAppender("List").clear();
a58c5e
-        ctx.getListAppender("EventLogger").clear();
a58c5e
     }
a58c5e
 }
a58c5e
diff --git a/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/OptionalTest.java b/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/OptionalTest.java
a58c5e
deleted file mode 100644
a58c5e
index a6e9fd5..0000000
a58c5e
--- a/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/OptionalTest.java
a58c5e
+++ /dev/null
a58c5e
@@ -1,69 +0,0 @@
a58c5e
-/*
a58c5e
- * Licensed to the Apache Software Foundation (ASF) under one or more
a58c5e
- * contributor license agreements. See the NOTICE file distributed with
a58c5e
- * this work for additional information regarding copyright ownership.
a58c5e
- * The ASF licenses this file to You under the Apache license, Version 2.0
a58c5e
- * (the "License"); you may not use this file except in compliance with
a58c5e
- * the License. You may obtain a copy of the License at
a58c5e
- *
a58c5e
- *      http://www.apache.org/licenses/LICENSE-2.0
a58c5e
- *
a58c5e
- * Unless required by applicable law or agreed to in writing, software
a58c5e
- * distributed under the License is distributed on an "AS IS" BASIS,
a58c5e
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
a58c5e
- * See the license for the specific language governing permissions and
a58c5e
- * limitations under the license.
a58c5e
- */
a58c5e
-package org.apache.logging.slf4j;
a58c5e
-
a58c5e
-import java.util.List;
a58c5e
-
a58c5e
-import org.apache.logging.log4j.junit.LoggerContextRule;
a58c5e
-import org.apache.logging.log4j.test.appender.ListAppender;
a58c5e
-import org.apache.logging.log4j.util.Strings;
a58c5e
-import org.junit.Before;
a58c5e
-import org.junit.ClassRule;
a58c5e
-import org.junit.Test;
a58c5e
-import org.slf4j.Logger;
a58c5e
-import org.slf4j.LoggerFactory;
a58c5e
-import org.slf4j.MDC;
a58c5e
-import org.slf4j.Marker;
a58c5e
-import org.slf4j.MarkerFactory;
a58c5e
-
a58c5e
-import static org.junit.Assert.*;
a58c5e
-
a58c5e
-/**
a58c5e
- *
a58c5e
- */
a58c5e
-public class OptionalTest {
a58c5e
-
a58c5e
-    private static final String CONFIG = "log4j-test1.xml";
a58c5e
-
a58c5e
-    @ClassRule
a58c5e
-    public static final LoggerContextRule CTX = new LoggerContextRule(CONFIG);
a58c5e
-
a58c5e
-    Logger logger = LoggerFactory.getLogger("EventLogger");
a58c5e
-    Marker marker = MarkerFactory.getMarker("EVENT");
a58c5e
-
a58c5e
-    @Test
a58c5e
-    public void testEventLogger() {
a58c5e
-        logger.info(marker, "This is a test");
a58c5e
-        MDC.clear();
a58c5e
-        verify("EventLogger", "o.a.l.s.OptionalTest This is a test" + Strings.LINE_SEPARATOR);
a58c5e
-    }
a58c5e
-
a58c5e
-    private void verify(final String name, final String expected) {
a58c5e
-        final ListAppender listApp = CTX.getListAppender(name);
a58c5e
-        final List<String> events = listApp.getMessages();
a58c5e
-        assertTrue("Incorrect number of messages. Expected 1 Actual " + events.size(), events.size()== 1);
a58c5e
-        final String actual = events.get(0);
a58c5e
-        assertEquals("Incorrect message. Expected " + expected + ". Actual " + actual, expected, actual);
a58c5e
-        listApp.clear();
a58c5e
-    }
a58c5e
-
a58c5e
-    @Before
a58c5e
-    public void cleanup() {
a58c5e
-        CTX.getListAppender("List").clear();
a58c5e
-        CTX.getListAppender("EventLogger").clear();
a58c5e
-    }
a58c5e
-}
a58c5e
diff --git a/log4j-slf4j-impl/src/test/resources/log4j-test1.xml b/log4j-slf4j-impl/src/test/resources/log4j-test1.xml
a58c5e
index a64bdfa..07a2be6 100644
a58c5e
--- a/log4j-slf4j-impl/src/test/resources/log4j-test1.xml
a58c5e
+++ b/log4j-slf4j-impl/src/test/resources/log4j-test1.xml
a58c5e
@@ -6,9 +6,6 @@
a58c5e
   <ThresholdFilter level="trace"/>
a58c5e
 
a58c5e
   <Appenders>
a58c5e
-    <List name="EventLogger">
a58c5e
-      <PatternLayout pattern="%C{1.} %m%n"/>
a58c5e
-    </List>
a58c5e
     <Console name="STDOUT">
a58c5e
       <PatternLayout pattern="%C{1.} %m MDC%X%n"/>
a58c5e
     </Console>
a58c5e
@@ -24,10 +21,6 @@
a58c5e
   </Appenders>
a58c5e
 
a58c5e
   <Loggers>
a58c5e
-    <Logger name="EventLogger" level="info" additivity="false">
a58c5e
-      <AppenderRef ref="EventLogger"/>
a58c5e
-    </Logger>>
a58c5e
-
a58c5e
     <Logger name="org.apache.logging.log4j.test2" level="debug" additivity="false">
a58c5e
       <AppenderRef ref="File"/>
a58c5e
     </Logger>