logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bbrou...@apache.org
Subject svn commit: r1610467 - 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/status/ log4j-core/src/main/java/org/apache/logging/log4j/core/jmx/
Date Mon, 14 Jul 2014 17:37:42 GMT
Author: bbrouwer
Date: Mon Jul 14 17:37:42 2014
New Revision: 1610467

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

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/StatusListener.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/status/StatusConsoleListener.java
    logging/log4j/log4j2/branches/LOG4J2-609/log4j-core/src/main/java/org/apache/logging/log4j/core/jmx/StatusLoggerAdmin.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=1610467&r1=1610466&r2=1610467&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
Mon Jul 14 17:37:42 2014
@@ -23,7 +23,6 @@ import java.text.SimpleDateFormat;
 import java.util.Date;
 
 import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.Marker;
 import org.apache.logging.log4j.message.Message;
 
 /**
@@ -35,7 +34,6 @@ public class StatusData implements Seria
     private final long timestamp;
     private final StackTraceElement caller;
     private final Level level;
-    private final Marker marker;
     private final Message msg;
     private final Throwable throwable;
 
@@ -46,11 +44,10 @@ public class StatusData implements Seria
      * @param msg The message String.
      * @param t The Error or Exception that occurred.
      */
-    public StatusData(final StackTraceElement caller, final Level level, final Marker marker,
final Message msg, final Throwable t) {
+    StatusData(final StackTraceElement caller, final Level level, final Message msg, final
Throwable t) {
         this.timestamp = System.currentTimeMillis();
         this.caller = caller;
         this.level = level;
-        this.marker = marker;
         this.msg = msg;
         this.throwable = t;
     }
@@ -78,14 +75,6 @@ public class StatusData implements Seria
     public Level getLevel() {
         return level;
     }
-    
-    /**
-     * Returns the logging marker for the event.
-     * @return The logging marker.
-     */
-    public Marker getMarker() {
-        return marker;
-    }
 
     /**
      * Returns the message associated with the event.

Modified: logging/log4j/log4j2/branches/LOG4J2-609/log4j-api/src/main/java/org/apache/logging/log4j/status/StatusListener.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/branches/LOG4J2-609/log4j-api/src/main/java/org/apache/logging/log4j/status/StatusListener.java?rev=1610467&r1=1610466&r2=1610467&view=diff
==============================================================================
--- logging/log4j/log4j2/branches/LOG4J2-609/log4j-api/src/main/java/org/apache/logging/log4j/status/StatusListener.java
(original)
+++ logging/log4j/log4j2/branches/LOG4J2-609/log4j-api/src/main/java/org/apache/logging/log4j/status/StatusListener.java
Mon Jul 14 17:37:42 2014
@@ -19,6 +19,8 @@ package org.apache.logging.log4j.status;
 import java.io.Closeable;
 import java.util.EventListener;
 
+import org.apache.logging.log4j.Level;
+
 /**
  * Interface that allows implementers to be notified of events in the logging system.
  */
@@ -29,4 +31,10 @@ public interface StatusListener extends 
      * @param data The StatusData for the event.
      */
     void log(StatusData data);
+
+    /**
+     * Return the Log Level that this listener wants included.
+     * @return the Log Level.
+     */
+    Level getStatusLevel();
 }

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=1610467&r1=1610466&r2=1610467&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
Mon Jul 14 17:37:42 2014
@@ -186,7 +186,7 @@ public final class StatusLogger extends 
         if (fqcn != null) {
             element = getStackTraceElement(fqcn, Thread.currentThread().getStackTrace());
         }
-        final StatusData data = new StatusData(element, level, marker, msg, t);
+        final StatusData data = new StatusData(element, level, msg, t);
         msgLock.lock();
         try {
             messages.add(data);
@@ -195,7 +195,9 @@ public final class StatusLogger extends 
         }
         if (listeners.size() > 0) {
             for (final StatusListener listener : listeners) {
-                listener.log(data);
+                if (data.getLevel().isMoreSpecificThan(listener.getStatusLevel())) {
+                    listener.log(data);
+                }
             }
         } else {
             logger.logMessage(fqcn, level, marker, msg, t);

Modified: logging/log4j/log4j2/branches/LOG4J2-609/log4j-core/src/main/java/org/apache/logging/log4j/core/config/status/StatusConsoleListener.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/branches/LOG4J2-609/log4j-core/src/main/java/org/apache/logging/log4j/core/config/status/StatusConsoleListener.java?rev=1610467&r1=1610466&r2=1610467&view=diff
==============================================================================
--- logging/log4j/log4j2/branches/LOG4J2-609/log4j-core/src/main/java/org/apache/logging/log4j/core/config/status/StatusConsoleListener.java
(original)
+++ logging/log4j/log4j2/branches/LOG4J2-609/log4j-core/src/main/java/org/apache/logging/log4j/core/config/status/StatusConsoleListener.java
Mon Jul 14 17:37:42 2014
@@ -66,9 +66,6 @@ public abstract class StatusConsoleListe
     }
 
     protected boolean isEnabledFor(final StatusData data) {
-        if (level.isMoreSpecificThan(data.getLevel())) {
-        	return false;
-        } 
         if (filters == null) {
         	return true;
         }

Modified: logging/log4j/log4j2/branches/LOG4J2-609/log4j-core/src/main/java/org/apache/logging/log4j/core/jmx/StatusLoggerAdmin.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/branches/LOG4J2-609/log4j-core/src/main/java/org/apache/logging/log4j/core/jmx/StatusLoggerAdmin.java?rev=1610467&r1=1610466&r2=1610467&view=diff
==============================================================================
--- logging/log4j/log4j2/branches/LOG4J2-609/log4j-core/src/main/java/org/apache/logging/log4j/core/jmx/StatusLoggerAdmin.java
(original)
+++ logging/log4j/log4j2/branches/LOG4J2-609/log4j-core/src/main/java/org/apache/logging/log4j/core/jmx/StatusLoggerAdmin.java
Mon Jul 14 17:37:42 2014
@@ -95,6 +95,11 @@ public class StatusLoggerAdmin extends N
     }
 
     @Override
+    public Level getStatusLevel() {
+        return this.level;
+    }
+
+    @Override
     public void setLevel(final String level) {
         this.level = Level.toLevel(level, Level.ERROR);
     }
@@ -113,15 +118,13 @@ public class StatusLoggerAdmin extends N
      */
     @Override
     public void log(final StatusData data) {
-        if (level.isLessSpecificThan(data.getLevel())) {
-	    	final Notification notifMsg = new Notification(NOTIF_TYPE_MESSAGE, getObjectName(),
nextSeqNo(), now(),
-	                data.getFormattedStatus());
-	        sendNotification(notifMsg);
-	
-	        final Notification notifData = new Notification(NOTIF_TYPE_DATA, getObjectName(),
nextSeqNo(), now());
-	        notifData.setUserData(data);
-	        sendNotification(notifData);
-        }
+        final Notification notifMsg = new Notification(NOTIF_TYPE_MESSAGE, getObjectName(),
nextSeqNo(), now(),
+                data.getFormattedStatus());
+        sendNotification(notifMsg);
+
+        final Notification notifData = new Notification(NOTIF_TYPE_DATA, getObjectName(),
nextSeqNo(), now());
+        notifData.setUserData(data);
+        sendNotification(notifData);
     }
 
     /**



Mime
View raw message