logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgo...@apache.org
Subject svn commit: r1178316 - in /logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers: log4j2-api/src/main/java/org/apache/logging/log4j/message/ log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/ log4j2-core/src/test/java/org/apache/logging/...
Date Mon, 03 Oct 2011 07:31:55 GMT
Author: rgoers
Date: Mon Oct  3 07:31:55 2011
New Revision: 1178316

URL: http://svn.apache.org/viewvc?rev=1178316&view=rev
Log:
Add suppressException parameter to all Appenders

Added:
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/DeferredMessage.java
Modified:
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/ConsoleAppender.java
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/JMSQueueAppender.java
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/JMSTopicAppender.java
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/net/JMSQueueTest.java
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/net/JMSTopicTest.java
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/net/SocketServerTest.java

Added: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/DeferredMessage.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/DeferredMessage.java?rev=1178316&view=auto
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/DeferredMessage.java
(added)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/DeferredMessage.java
Mon Oct  3 07:31:55 2011
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ */
+package org.apache.logging.log4j.message;
+
+/**
+* A Message that supports lazy initialization.
+*/
+public interface DeferredMessage {
+
+  /**
+  * Lazily perform expensive initialization tasks that would otherwise occur in
+  * the constructor. For example, cloning mutable message content or gathering
+  * data to be logged. Loggers are required to call this method immediately
+  * after determining this Message is likely to be logged based on the log
+  * Level and Marker, and before returning from the log method (i.e.
+  * trace(message)). The Logger will not call initialize() if no logging will be
+  * performed based on Level and Marker.
+  *
+  * Initialization must be performed before returning from the first call to this
+  * method. Subsequent calls must be no-ops.
+  *
+  * @return This Message.
+  */
+ Message initialize();
+
+}

Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/ConsoleAppender.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/ConsoleAppender.java?rev=1178316&r1=1178315&r2=1178316&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/ConsoleAppender.java
(original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/ConsoleAppender.java
Mon Oct  3 07:31:55 2011
@@ -49,25 +49,31 @@ public class ConsoleAppender extends Out
     }
 
     public ConsoleAppender(String name, Layout layout) {
-        this(name, layout, null, getManager(Target.SYSTEM_OUT));
+        this(name, layout, null, getManager(Target.SYSTEM_OUT), true);
+    }
 
+    public ConsoleAppender(String name, Layout layout, boolean handleExceptions) {
+        this(name, layout, null, getManager(Target.SYSTEM_OUT), handleExceptions);
     }
 
-    public ConsoleAppender(String name, Layout layout, Filters filters, OutputStreamManager
manager) {
-        super(name, layout, filters, true, true, manager);
+    public ConsoleAppender(String name, Layout layout, Filters filters, OutputStreamManager
manager,
+                           boolean handleExceptions) {
+        super(name, layout, filters, handleExceptions, true, manager);
     }
 
     @PluginFactory
     public static ConsoleAppender createAppender(@PluginElement("layout") Layout layout,
                                                  @PluginElement("filters") Filters filters,
                                                  @PluginAttr("target") String t,
-                                                 @PluginAttr("name") String name) {
+                                                 @PluginAttr("name") String name,
+                                                 @PluginAttr("suppressExceptions") String
suppress) {
         if (name == null) {
             logger.error("No name provided for ConsoleAppender");
             return null;
         }
+        boolean handleExceptions = suppress == null ? true : Boolean.valueOf(suppress);
         Target target = t == null ? Target.SYSTEM_OUT : Target.valueOf(t);
-        return new ConsoleAppender(name, layout, filters, getManager(target));
+        return new ConsoleAppender(name, layout, filters, getManager(target), handleExceptions);
     }
 
     private static OutputStreamManager getManager(Target target) {

Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/JMSQueueAppender.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/JMSQueueAppender.java?rev=1178316&r1=1178315&r2=1178316&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/JMSQueueAppender.java
(original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/JMSQueueAppender.java
Mon Oct  3 07:31:55 2011
@@ -34,8 +34,9 @@ public class JMSQueueAppender extends Ap
 
     private final JMSQueueManager manager;
 
-    public JMSQueueAppender(String name, Filters filters, Layout layout, JMSQueueManager
manager) {
-        super(name, filters, layout);
+    public JMSQueueAppender(String name, Filters filters, Layout layout, JMSQueueManager
manager,
+                            boolean handleExceptions) {
+        super(name, filters, layout, handleExceptions);
         this.manager = manager;
     }
 
@@ -63,9 +64,11 @@ public class JMSQueueAppender extends Ap
                                                   @PluginAttr("userName") String userName,
                                                   @PluginAttr("password") String password,
                                                   @PluginElement("layout") Layout layout,
-                                                  @PluginElement("filters") Filters filters)
{
+                                                  @PluginElement("filters") Filters filters,
+                                                  @PluginAttr("suppressExceptions") String
suppress) {
 
         String name = "JMSQueue" + factoryBindingName + "." + queueBindingName;
+        boolean handleExceptions = suppress == null ? true : Boolean.valueOf(suppress);
         JMSQueueManager manager = JMSQueueManager.getJMSQueueManager(factoryName, providerURL,
urlPkgPrefixes,
             securityPrincipalName, securityCredentials, factoryBindingName, queueBindingName,
userName, password);
         if (manager == null) {
@@ -74,6 +77,6 @@ public class JMSQueueAppender extends Ap
         if (layout == null) {
             layout = SerializedLayout.createLayout();
         }
-        return new JMSQueueAppender(name, filters, layout, manager);
+        return new JMSQueueAppender(name, filters, layout, manager, handleExceptions);
     }
 }

Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/JMSTopicAppender.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/JMSTopicAppender.java?rev=1178316&r1=1178315&r2=1178316&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/JMSTopicAppender.java
(original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/JMSTopicAppender.java
Mon Oct  3 07:31:55 2011
@@ -34,8 +34,9 @@ public class JMSTopicAppender extends Ap
 
     private final JMSTopicManager manager;
 
-    public JMSTopicAppender(String name, Filters filters, Layout layout, JMSTopicManager
manager) {
-        super(name, filters, layout);
+    public JMSTopicAppender(String name, Filters filters, Layout layout, JMSTopicManager
manager,
+                            boolean handleExceptions) {
+        super(name, filters, layout, handleExceptions);
         this.manager = manager;
     }
 
@@ -63,9 +64,11 @@ public class JMSTopicAppender extends Ap
                                                   @PluginAttr("userName") String userName,
                                                   @PluginAttr("password") String password,
                                                   @PluginElement("layout") Layout layout,
-                                                  @PluginElement("filters") Filters filters)
{
+                                                  @PluginElement("filters") Filters filters,
+                                                  @PluginAttr("suppressExceptions") String
suppress) {
 
         String name = "JMSTopic" + factoryBindingName + "." + topicBindingName;
+        boolean handleExceptions = suppress == null ? true : Boolean.valueOf(suppress);
         JMSTopicManager manager = JMSTopicManager.getJMSTopicManager(factoryName, providerURL,
urlPkgPrefixes,
             securityPrincipalName, securityCredentials, factoryBindingName, topicBindingName,
userName, password);
         if (manager == null) {
@@ -74,6 +77,6 @@ public class JMSTopicAppender extends Ap
         if (layout == null) {
             layout = SerializedLayout.createLayout();
         }
-        return new JMSTopicAppender(name, filters, layout, manager);
+        return new JMSTopicAppender(name, filters, layout, manager, handleExceptions);
     }
 }

Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/net/JMSQueueTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/net/JMSQueueTest.java?rev=1178316&r1=1178315&r2=1178316&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/net/JMSQueueTest.java
(original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/net/JMSQueueTest.java
Mon Oct  3 07:31:55 2011
@@ -97,13 +97,13 @@ public class JMSQueueTest {
         Filter serverFilter = new MessageFilter(Filter.Result.DENY, Filter.Result.NEUTRAL);
         Filters clientFilters = Filters.createFilters(new Filter[] {clientFilter});
         JMSQueueAppender appender = JMSQueueAppender.createAppender(null, null, null, null,
null, FACTORY_NAME,
-                QUEUE_NAME, null, null, null, clientFilters);
+                QUEUE_NAME, null, null, null, clientFilters, "true");
         appender.start();
         Filters serverFilters = Filters.createFilters(new Filter[] {serverFilter});
         ListAppender listApp = new ListAppender("Events", serverFilters, null, false, false);
         listApp.start();
         PatternLayout layout = new PatternLayout("%m %ex%n");
-        ConsoleAppender console = ConsoleAppender.createAppender(layout, null, "SYSTEM_OUT",
"Console");
+        ConsoleAppender console = ConsoleAppender.createAppender(layout, null, "SYSTEM_OUT",
"Console", "true");
         console.start();
         Logger serverLogger = ctx.getLogger(JMSTopicReceiver.class.getName());
         serverLogger.addAppender(console);

Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/net/JMSTopicTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/net/JMSTopicTest.java?rev=1178316&r1=1178315&r2=1178316&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/net/JMSTopicTest.java
(original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/net/JMSTopicTest.java
Mon Oct  3 07:31:55 2011
@@ -97,13 +97,13 @@ public class JMSTopicTest {
         Filter serverFilter = new MessageFilter(Filter.Result.DENY, Filter.Result.NEUTRAL);
         Filters clientFilters = Filters.createFilters(new Filter[] {clientFilter});
         JMSTopicAppender appender = JMSTopicAppender.createAppender(null, null, null, null,
null, FACTORY_NAME,
-                TOPIC_NAME, null, null, null, clientFilters);
+                TOPIC_NAME, null, null, null, clientFilters, "true");
         appender.start();
         Filters serverFilters = Filters.createFilters(new Filter[] {serverFilter});
         ListAppender listApp = new ListAppender("Events", serverFilters, null, false, false);
         listApp.start();
         PatternLayout layout = new PatternLayout("%m %ex%n");
-        ConsoleAppender console = ConsoleAppender.createAppender(layout, null, "SYSTEM_OUT",
"Console");
+        ConsoleAppender console = ConsoleAppender.createAppender(layout, null, "SYSTEM_OUT",
"Console", "true");
         console.start();
         Logger serverLogger = ctx.getLogger(JMSTopicReceiver.class.getName());
         serverLogger.addAppender(console);

Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/net/SocketServerTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/net/SocketServerTest.java?rev=1178316&r1=1178315&r2=1178316&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/net/SocketServerTest.java
(original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/net/SocketServerTest.java
Mon Oct  3 07:31:55 2011
@@ -110,7 +110,7 @@ public class SocketServerTest {
         ListAppender listApp = new ListAppender("Events", serverFilters, null, false, false);
         appender.start();
         PatternLayout layout = new PatternLayout("%m %ex%n");
-        ConsoleAppender console = ConsoleAppender.createAppender(layout, null, "SYSTEM_OUT",
"Console");
+        ConsoleAppender console = ConsoleAppender.createAppender(layout, null, "SYSTEM_OUT",
"Console", "true");
         Logger serverLogger = ctx.getLogger(SocketServer.class.getName());
         serverLogger.addAppender(console);
         serverLogger.setAdditive(false);



Mime
View raw message