logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgo...@apache.org
Subject svn commit: r1553789 - in /logging/log4j/log4j2/trunk/log4j-core/src: main/java/org/apache/logging/log4j/core/config/JSONConfiguration.java test/java/org/apache/logging/log4j/core/AppenderRefLevelJsonTest.java test/resources/log4j-reference-level.json
Date Sat, 28 Dec 2013 06:30:33 GMT
Author: rgoers
Date: Sat Dec 28 06:30:33 2013
New Revision: 1553789

URL: http://svn.apache.org/r1553789
Log:
LOG4J2-464 - Support arrays in sub-elements

Added:
    logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/AppenderRefLevelJsonTest.java
      - copied, changed from r1542882, logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/AppenderRefLevelTest.java
    logging/log4j/log4j2/trunk/log4j-core/src/test/resources/log4j-reference-level.json
      - copied, changed from r1542882, logging/log4j/log4j2/trunk/log4j-core/src/test/resources/log4j-reference-level.xml
Modified:
    logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/JSONConfiguration.java

Modified: logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/JSONConfiguration.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/JSONConfiguration.java?rev=1553789&r1=1553788&r2=1553789&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/JSONConfiguration.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/JSONConfiguration.java
Sat Dec 28 06:30:33 2013
@@ -232,7 +232,16 @@ public class JSONConfiguration extends B
                             if (itemEntry.getValue().isObject()) {
                                 LOGGER.debug("Processing node for object " + itemEntry.getKey());
                                 itemChildren.add(constructNode(itemEntry.getKey(), item,
itemEntry.getValue()));
+                            } else if (itemEntry.getValue().isArray()) {
+                                JsonNode array = itemEntry.getValue();
+                                String entryName = itemEntry.getKey();
+                                LOGGER.debug("Processing array for object " + entryName);
+                                final PluginType<?> itemEntryType = pluginManager.getPluginType(entryName);
+                                for (int j = 0; j < array.size(); ++j) {
+                                    itemChildren.add(constructNode(entryName, item, array.get(j)));
+                                }
                             }
+
                         }
                         children.add(item);
                     }
@@ -240,6 +249,8 @@ public class JSONConfiguration extends B
                     LOGGER.debug("Processing node for object " + entry.getKey());
                     children.add(constructNode(entry.getKey(), node, n));
                 }
+            } else {
+                LOGGER.debug("Node {} is of type {}", entry.getKey(), n.getNodeType());
             }
         }
 

Copied: logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/AppenderRefLevelJsonTest.java
(from r1542882, logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/AppenderRefLevelTest.java)
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/AppenderRefLevelJsonTest.java?p2=logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/AppenderRefLevelJsonTest.java&p1=logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/AppenderRefLevelTest.java&r1=1542882&r2=1553789&rev=1553789&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/AppenderRefLevelTest.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/AppenderRefLevelJsonTest.java
Sat Dec 28 06:30:33 2013
@@ -16,11 +16,6 @@
  */
 package org.apache.logging.log4j.core;
 
-import static org.junit.Assert.assertTrue;
-
-import java.util.List;
-import java.util.Map;
-
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Marker;
 import org.apache.logging.log4j.MarkerManager;
@@ -33,12 +28,17 @@ import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
+import java.util.List;
+import java.util.Map;
+
+import static org.junit.Assert.assertTrue;
+
 /**
  *
  */
-public class AppenderRefLevelTest {
+public class AppenderRefLevelJsonTest {
 
-    private static final String CONFIG = "log4j-reference-level.xml";
+    private static final String CONFIG = "log4j-reference-level.json";
     private static Configuration config;
     private static ListAppender app1;
     private static ListAppender app2;

Copied: logging/log4j/log4j2/trunk/log4j-core/src/test/resources/log4j-reference-level.json
(from r1542882, logging/log4j/log4j2/trunk/log4j-core/src/test/resources/log4j-reference-level.xml)
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/test/resources/log4j-reference-level.json?p2=logging/log4j/log4j2/trunk/log4j-core/src/test/resources/log4j-reference-level.json&p1=logging/log4j/log4j2/trunk/log4j-core/src/test/resources/log4j-reference-level.xml&r1=1542882&r2=1553789&rev=1553789&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/test/resources/log4j-reference-level.xml (original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/test/resources/log4j-reference-level.json Sat
Dec 28 06:30:33 2013
@@ -1,50 +1,38 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements.  See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License.  You may obtain a copy of the License at
-
-      http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<Configuration status="warn" name="XMLConfigTest" packages="org.apache.logging.log4j.test">
-  <Appenders>
-    <Console name="STDOUT">
-      <PatternLayout pattern="%m%n"/>
-    </Console>
-    <List name="LIST1"/>
-    <List name="LIST2"/>
-  </Appenders>
-
-  <Loggers>
-    <Logger name="org.apache.logging.log4j.test1" level="trace" additivity="false">
-      <AppenderRef ref="LIST1" level="trace"/>
-      <AppenderRef ref="LIST2" level="error"/>
-    </Logger>>
-
-    <Logger name="org.apache.logging.log4j.test2" level="debug" additivity="false">
-      <AppenderRef ref="LIST1" level="WARN"/>
-      <AppenderRef ref="LIST2" level="debug"/>
-    </Logger>>
-
-    <Logger name="org.apache.logging.log4j.test3" level="trace" additivity="false">
-      <AppenderRef ref="LIST1" level="trace">
-          <MarkerFilter marker="TEST" onmatch="deny" onmismatch="accept"/>
-      </AppenderRef>
-    </Logger>>
-
-    <Root level="error">
-      <AppenderRef ref="STDOUT"/>
-    </Root>
-  </Loggers>
-
-</Configuration>
\ No newline at end of file
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+{ "configuration": { "status": "debug", "XMLConfigTest": "RoutingTest", "packages": "org.apache.logging.log4j.test",
+    "appenders": {
+        "appender": [
+            { "type": "Console", "name": "STDOUT", "PatternLayout": { "pattern": "%m%n" }},
+            { "type": "List", "name": "LIST1"},
+            { "type": "List", "name": "LIST2"}
+        ]
+    },
+    "loggers": {
+        "logger": [
+            { "name": "org.apache.logging.log4j.test1", "level": "trace", "additivity": "false",
+                "AppenderRef": [{ "ref": "LIST1", "level": "trace" }, {"ref": "LIST2", "level":
"error"}]},
+            { "name": "org.apache.logging.log4j.test2", "level": "debug", "additivity": "false",
+                "AppenderRef": [{ "ref": "LIST1", "level": "warn" }, {"ref": "LIST2", "level":
"debug"}]},
+            { "name": "org.apache.logging.log4j.test3", "level": "trace", "additivity": "false",
+                "AppenderRef": {"ref": "LIST1", "level": "trace",
+                    "MarkerFilter": {"marker" : "TEST", "onMatch": "deny", "onMismatch":
"accept"}} }
+        ],
+        "root": { "level": "error", "AppenderRef": { "ref": "STDOUT" }}
+    }
+  }
+}
\ No newline at end of file



Mime
View raw message