logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bbrou...@apache.org
Subject svn commit: r1610811 - in /logging/log4j/log4j2/branches/LOG4J2-609: log4j-api/src/main/java/org/apache/logging/log4j/status/ log4j-core/src/main/java/org/apache/logging/log4j/core/config/json/ log4j-core/src/main/java/org/apache/logging/log4j/core/con...
Date Tue, 15 Jul 2014 19:02:03 GMT
Author: bbrouwer
Date: Tue Jul 15 19:02:02 2014
New Revision: 1610811

URL: http://svn.apache.org/r1610811
Log:
Try to simplify the StatusLogger stuff

Removed:
    logging/log4j/log4j2/branches/LOG4J2-609/log4j-core/src/main/java/org/apache/logging/log4j/core/config/status/StatusConfiguration.java
    logging/log4j/log4j2/branches/LOG4J2-609/log4j-core/src/main/java/org/apache/logging/log4j/core/config/status/StatusConsoleListener.java
    logging/log4j/log4j2/branches/LOG4J2-609/log4j-core/src/main/java/org/apache/logging/log4j/core/config/status/StatusStdErrListener.java
    logging/log4j/log4j2/branches/LOG4J2-609/log4j-core/src/main/java/org/apache/logging/log4j/core/config/status/StatusStdOutListener.java
Modified:
    logging/log4j/log4j2/branches/LOG4J2-609/log4j-api/src/main/java/org/apache/logging/log4j/status/StatusData.java
    logging/log4j/log4j2/branches/LOG4J2-609/log4j-api/src/main/java/org/apache/logging/log4j/status/StatusLogger.java
    logging/log4j/log4j2/branches/LOG4J2-609/log4j-core/src/main/java/org/apache/logging/log4j/core/config/json/JsonConfiguration.java
    logging/log4j/log4j2/branches/LOG4J2-609/log4j-core/src/main/java/org/apache/logging/log4j/core/config/xml/XmlConfiguration.java

Modified: logging/log4j/log4j2/branches/LOG4J2-609/log4j-api/src/main/java/org/apache/logging/log4j/status/StatusData.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/branches/LOG4J2-609/log4j-api/src/main/java/org/apache/logging/log4j/status/StatusData.java?rev=1610811&r1=1610810&r2=1610811&view=diff
==============================================================================
--- logging/log4j/log4j2/branches/LOG4J2-609/log4j-api/src/main/java/org/apache/logging/log4j/status/StatusData.java
(original)
+++ logging/log4j/log4j2/branches/LOG4J2-609/log4j-api/src/main/java/org/apache/logging/log4j/status/StatusData.java
Tue Jul 15 19:02:02 2014
@@ -44,7 +44,7 @@ public class StatusData implements Seria
      * @param msg The message String.
      * @param t The Error or Exception that occurred.
      */
-    StatusData(final StackTraceElement caller, final Level level, final Message msg, final
Throwable t) {
+    public StatusData(final StackTraceElement caller, final Level level, final Message msg,
final Throwable t) {
         this.timestamp = System.currentTimeMillis();
         this.caller = caller;
         this.level = level;

Modified: logging/log4j/log4j2/branches/LOG4J2-609/log4j-api/src/main/java/org/apache/logging/log4j/status/StatusLogger.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/branches/LOG4J2-609/log4j-api/src/main/java/org/apache/logging/log4j/status/StatusLogger.java?rev=1610811&r1=1610810&r2=1610811&view=diff
==============================================================================
--- logging/log4j/log4j2/branches/LOG4J2-609/log4j-api/src/main/java/org/apache/logging/log4j/status/StatusLogger.java
(original)
+++ logging/log4j/log4j2/branches/LOG4J2-609/log4j-api/src/main/java/org/apache/logging/log4j/status/StatusLogger.java
Tue Jul 15 19:02:02 2014
@@ -18,6 +18,7 @@ package org.apache.logging.log4j.status;
 
 import java.io.Closeable;
 import java.io.IOException;
+import java.io.PrintStream;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
@@ -53,7 +54,7 @@ public final class StatusLogger extends 
     private static final String NOT_AVAIL = "?";
 
     private static final PropertiesUtil PROPS = new PropertiesUtil("log4j2.StatusLogger.properties");
-
+    
     private static final int MAX_ENTRIES = PROPS.getIntegerProperty(MAX_STATUS_ENTRIES, 200);
 
     private static final StatusLogger STATUS_LOGGER = new StatusLogger();
@@ -67,8 +68,11 @@ public final class StatusLogger extends 
     private final Lock msgLock = new ReentrantLock();
 
     private StatusLogger() {
-        this.logger = new SimpleLogger("StatusLogger", Level.ERROR, false, true, false, false,
Strings.EMPTY, null, PROPS,
-            System.err);
+    	final Level consoleLevel = Level.toLevel(PROPS.getStringProperty("log4j2.StatusLogger.console.level"),
Level.ERROR);
+    	final PrintStream consoleDest ="out".equalsIgnoreCase(PROPS.getStringProperty("log4j2.StatusLogger.console.destination"))
? System.out : System.err; 
+    			
+		this.logger = new SimpleLogger("StatusLogger", consoleLevel, false,
+				true, false, false, Strings.EMPTY, null, PROPS, consoleDest);
     }
 
     /**
@@ -182,6 +186,7 @@ public final class StatusLogger extends 
      */
     @Override
     public void logMessage(final String fqcn, final Level level, final Marker marker, final
Message msg, final Throwable t) {
+        logger.logMessage(fqcn, level, marker, msg, t);
         StackTraceElement element = null;
         if (fqcn != null) {
             element = getStackTraceElement(fqcn, Thread.currentThread().getStackTrace());
@@ -193,14 +198,10 @@ public final class StatusLogger extends 
         } finally {
             msgLock.unlock();
         }
-        if (listeners.size() > 0) {
-            for (final StatusListener listener : listeners) {
-                if (data.getLevel().isMoreSpecificThan(listener.getStatusLevel())) {
-                    listener.log(data);
-                }
+        for (final StatusListener listener : listeners) {
+            if (data.getLevel().isMoreSpecificThan(listener.getStatusLevel())) {
+                listener.log(data);
             }
-        } else {
-            logger.logMessage(fqcn, level, marker, msg, t);
         }
     }
 
@@ -250,10 +251,15 @@ public final class StatusLogger extends 
 
     @Override
     public boolean isEnabled(final Level level, final Marker marker) {
-        if (listeners.isEmpty()) {
-            return false;
+        if (logger.isEnabled(level)) {
+        	return true;
         }
-        return logger.isEnabled(level, marker);
+    	for (StatusListener listener : listeners) {
+    		if (level.isLessSpecificThan(listener.getStatusLevel())) {
+    			return true;
+    		}
+    	}
+        return false;
     }
 
     /**

Modified: logging/log4j/log4j2/branches/LOG4J2-609/log4j-core/src/main/java/org/apache/logging/log4j/core/config/json/JsonConfiguration.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/branches/LOG4J2-609/log4j-core/src/main/java/org/apache/logging/log4j/core/config/json/JsonConfiguration.java?rev=1610811&r1=1610810&r2=1610811&view=diff
==============================================================================
--- logging/log4j/log4j2/branches/LOG4J2-609/log4j-core/src/main/java/org/apache/logging/log4j/core/config/json/JsonConfiguration.java
(original)
+++ logging/log4j/log4j2/branches/LOG4J2-609/log4j-core/src/main/java/org/apache/logging/log4j/core/config/json/JsonConfiguration.java
Tue Jul 15 19:02:02 2014
@@ -34,7 +34,6 @@ import org.apache.logging.log4j.core.con
 import org.apache.logging.log4j.core.config.plugins.util.PluginManager;
 import org.apache.logging.log4j.core.config.plugins.util.PluginType;
 import org.apache.logging.log4j.core.config.plugins.util.ResolverUtil;
-import org.apache.logging.log4j.core.config.status.StatusConfiguration;
 import org.apache.logging.log4j.core.util.Patterns;
 
 import com.fasterxml.jackson.core.JsonParser;
@@ -69,19 +68,11 @@ public class JsonConfiguration extends A
                 }
             }
             processAttributes(rootNode, root);
-            final StatusConfiguration statusConfig = new StatusConfiguration().withVerboseClasses(VERBOSE_CLASSES)
-                    .withStatus(getDefaultStatus());
             for (final Map.Entry<String, String> entry : rootNode.getAttributes().entrySet())
{
                 final String key = entry.getKey();
                 final String value = getStrSubstitutor().replace(entry.getValue());
-                if ("status".equalsIgnoreCase(key)) {
-                    statusConfig.withStatus(value);
-                } else if ("dest".equalsIgnoreCase(key)) {
-                    statusConfig.withDestination(value);
-                } else if ("shutdownHook".equalsIgnoreCase(key)) {
+                if ("shutdownHook".equalsIgnoreCase(key)) {
                     isShutdownHookEnabled = !"disable".equalsIgnoreCase(value);
-                } else if ("verbose".equalsIgnoreCase(entry.getKey())) {
-                    statusConfig.withVerbosity(value);
                 } else if ("packages".equalsIgnoreCase(key)) {
                     final String[] packages = value.split(Patterns.COMMA_SEPARATOR);
                     for (final String p : packages) {
@@ -98,7 +89,6 @@ public class JsonConfiguration extends A
                     createAdvertiser(value, configSource, buffer, "application/json");
                 }
             }
-            statusConfig.initialize();
             if (getName() == null) {
                 setName(configSource.getLocation());
             }

Modified: logging/log4j/log4j2/branches/LOG4J2-609/log4j-core/src/main/java/org/apache/logging/log4j/core/config/xml/XmlConfiguration.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/branches/LOG4J2-609/log4j-core/src/main/java/org/apache/logging/log4j/core/config/xml/XmlConfiguration.java?rev=1610811&r1=1610810&r2=1610811&view=diff
==============================================================================
--- logging/log4j/log4j2/branches/LOG4J2-609/log4j-core/src/main/java/org/apache/logging/log4j/core/config/xml/XmlConfiguration.java
(original)
+++ logging/log4j/log4j2/branches/LOG4J2-609/log4j-core/src/main/java/org/apache/logging/log4j/core/config/xml/XmlConfiguration.java
Tue Jul 15 19:02:02 2014
@@ -43,7 +43,6 @@ import org.apache.logging.log4j.core.con
 import org.apache.logging.log4j.core.config.plugins.util.PluginManager;
 import org.apache.logging.log4j.core.config.plugins.util.PluginType;
 import org.apache.logging.log4j.core.config.plugins.util.ResolverUtil;
-import org.apache.logging.log4j.core.config.status.StatusConfiguration;
 import org.apache.logging.log4j.core.util.Loader;
 import org.apache.logging.log4j.core.util.Patterns;
 import org.w3c.dom.Attr;
@@ -134,19 +133,11 @@ public class XmlConfiguration extends Ab
             final Document document = newDocumentBuilder().parse(source);
             rootElement = document.getDocumentElement();
             final Map<String, String> attrs = processAttributes(rootNode, rootElement);
-            final StatusConfiguration statusConfig = new StatusConfiguration().withVerboseClasses(VERBOSE_CLASSES)
-                    .withStatus(getDefaultStatus());
             for (final Map.Entry<String, String> entry : attrs.entrySet()) {
                 final String key = entry.getKey();
                 final String value = getStrSubstitutor().replace(entry.getValue());
-                if ("status".equalsIgnoreCase(key)) {
-                    statusConfig.withStatus(value);
-                } else if ("dest".equalsIgnoreCase(key)) {
-                    statusConfig.withDestination(value);
-                } else if ("shutdownHook".equalsIgnoreCase(key)) {
+                if ("shutdownHook".equalsIgnoreCase(key)) {
                     isShutdownHookEnabled = !"disable".equalsIgnoreCase(value);
-                } else if ("verbose".equalsIgnoreCase(key)) {
-                    statusConfig.withVerbosity(value);
                 } else if ("packages".equalsIgnoreCase(key)) {
                     final String[] packages = value.split(Patterns.COMMA_SEPARATOR);
                     for (final String p : packages) {
@@ -167,7 +158,6 @@ public class XmlConfiguration extends Ab
                     createAdvertiser(value, configSource, buffer, "text/xml");
                 }
             }
-            statusConfig.initialize();
         } catch (final SAXException domEx) {
             LOGGER.error("Error parsing " + configSource.getLocation(), domEx);
         } catch (final IOException ioe) {



Mime
View raw message