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

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