logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1580752 - in /logging/log4j/log4j2/trunk: log4j-api/src/main/java/org/apache/logging/log4j/ log4j-api/src/main/java/org/apache/logging/log4j/simple/ log4j-api/src/main/java/org/apache/logging/log4j/spi/ log4j-api/src/main/java/org/apache/l...
Date Mon, 24 Mar 2014 05:30:21 GMT
Author: ggregory
Date: Mon Mar 24 05:30:20 2014
New Revision: 1580752

URL: http://svn.apache.org/r1580752
Log:
<action issue="LOG4J2-576" dev="ggregory" type="add">
  Add org.apache.logging.log4j.Logger.getLevel().
</action>

Modified:
    logging/log4j/log4j2/trunk/log4j-api/src/main/java/org/apache/logging/log4j/Logger.java
    logging/log4j/log4j2/trunk/log4j-api/src/main/java/org/apache/logging/log4j/simple/SimpleLogger.java
    logging/log4j/log4j2/trunk/log4j-api/src/main/java/org/apache/logging/log4j/spi/AbstractLoggerWrapper.java
    logging/log4j/log4j2/trunk/log4j-api/src/main/java/org/apache/logging/log4j/status/StatusLogger.java
    logging/log4j/log4j2/trunk/log4j-api/src/test/java/org/apache/logging/log4j/AbstractLoggerTest.java
    logging/log4j/log4j2/trunk/log4j-api/src/test/java/org/apache/logging/log4j/TestLogger.java
    logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/Logger.java
    logging/log4j/log4j2/trunk/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLogger.java
    logging/log4j/log4j2/trunk/src/changes/changes.xml

Modified: logging/log4j/log4j2/trunk/log4j-api/src/main/java/org/apache/logging/log4j/Logger.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-api/src/main/java/org/apache/logging/log4j/Logger.java?rev=1580752&r1=1580751&r2=1580752&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-api/src/main/java/org/apache/logging/log4j/Logger.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-api/src/main/java/org/apache/logging/log4j/Logger.java
Mon Mar 24 05:30:20 2014
@@ -451,6 +451,13 @@ public interface Logger {
     void fatal(String message, Throwable t);
 
     /**
+     * Gets the Level associated with the Logger.
+     * 
+     * @return the Level associate with the Logger.
+     */
+    Level getLevel();
+    
+    /**
      * Gets the message factory used to convert message Objects and Strings into actual log
Messages.
      * 
      * @return the message factory.

Modified: logging/log4j/log4j2/trunk/log4j-api/src/main/java/org/apache/logging/log4j/simple/SimpleLogger.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-api/src/main/java/org/apache/logging/log4j/simple/SimpleLogger.java?rev=1580752&r1=1580751&r2=1580752&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-api/src/main/java/org/apache/logging/log4j/simple/SimpleLogger.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-api/src/main/java/org/apache/logging/log4j/simple/SimpleLogger.java
Mon Mar 24 05:30:20 2014
@@ -93,6 +93,11 @@ public class SimpleLogger extends Abstra
     }
 
     @Override
+    public Level getLevel() {
+        return level;
+    }
+
+    @Override
     public boolean isEnabled(final Level level, final Marker marker, final Message msg, final
Throwable t) {
         return this.level.intLevel() >= level.intLevel();
     }

Modified: logging/log4j/log4j2/trunk/log4j-api/src/main/java/org/apache/logging/log4j/spi/AbstractLoggerWrapper.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-api/src/main/java/org/apache/logging/log4j/spi/AbstractLoggerWrapper.java?rev=1580752&r1=1580751&r2=1580752&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-api/src/main/java/org/apache/logging/log4j/spi/AbstractLoggerWrapper.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-api/src/main/java/org/apache/logging/log4j/spi/AbstractLoggerWrapper.java
Mon Mar 24 05:30:20 2014
@@ -44,6 +44,11 @@ public class AbstractLoggerWrapper exten
         this.logger = logger;
     }
 
+    @Override
+    public Level getLevel() {
+        return logger.getLevel();
+    }
+
     /**
      * Detect if the event would be logged.
      * @param level The logging Level to check.
@@ -94,7 +99,7 @@ public class AbstractLoggerWrapper exten
     public boolean isEnabled(final Level level, final Marker marker, final String message,
final Object... params) {
         return logger.isEnabled(level, marker, message, params);
     }
-
+    
     /**
      * Detect if the event would be logged.
      * @param level The logging Level to check.
@@ -107,7 +112,7 @@ public class AbstractLoggerWrapper exten
     public boolean isEnabled(final Level level, final Marker marker, final String message,
final Throwable t) {
         return logger.isEnabled(level, marker, message, t);
     }
-    
+
     /**
      * Always log an event. This tends to be already guarded by an enabled check, so this
method 
      * should not check for the logger level again

Modified: logging/log4j/log4j2/trunk/log4j-api/src/main/java/org/apache/logging/log4j/status/StatusLogger.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-api/src/main/java/org/apache/logging/log4j/status/StatusLogger.java?rev=1580752&r1=1580751&r2=1580752&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-api/src/main/java/org/apache/logging/log4j/status/StatusLogger.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-api/src/main/java/org/apache/logging/log4j/status/StatusLogger.java
Mon Mar 24 05:30:20 2014
@@ -81,10 +81,6 @@ public final class StatusLogger extends 
         return STATUS_LOGGER;
     }
 
-    public Level getLevel() {
-        return logger.getLevel();
-    }
-
     public void setLevel(final Level level) {
         logger.setLevel(level);
     }
@@ -168,6 +164,10 @@ public final class StatusLogger extends 
         }
     }
 
+    @Override
+    public Level getLevel() {
+        return logger.getLevel();
+    }
 
     /**
      * Add an event.

Modified: logging/log4j/log4j2/trunk/log4j-api/src/test/java/org/apache/logging/log4j/AbstractLoggerTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-api/src/test/java/org/apache/logging/log4j/AbstractLoggerTest.java?rev=1580752&r1=1580751&r2=1580752&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-api/src/test/java/org/apache/logging/log4j/AbstractLoggerTest.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-api/src/test/java/org/apache/logging/log4j/AbstractLoggerTest.java
Mon Mar 24 05:30:20 2014
@@ -87,6 +87,11 @@ public class AbstractLoggerTest extends 
     };
 
     @Override
+    public Level getLevel() {
+        return currentLevel;
+    }
+
+    @Override
     public boolean isEnabled(final Level level, final Marker marker, final Message data,
final Throwable t) {
         assertTrue("Incorrect Level. Expected " + currentLevel + ", actual " + level, level.equals(currentLevel));
         if (marker == null) {
@@ -698,4 +703,5 @@ public class AbstractLoggerTest extends 
         currentEvent = events[14];
         warn(MarkerManager.getMarker("TEST"), simple);
     }
+
 }

Modified: logging/log4j/log4j2/trunk/log4j-api/src/test/java/org/apache/logging/log4j/TestLogger.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-api/src/test/java/org/apache/logging/log4j/TestLogger.java?rev=1580752&r1=1580751&r2=1580752&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-api/src/test/java/org/apache/logging/log4j/TestLogger.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-api/src/test/java/org/apache/logging/log4j/TestLogger.java
Mon Mar 24 05:30:20 2014
@@ -109,4 +109,9 @@ public class TestLogger extends Abstract
     public boolean isEnabled(final Level level, final Marker marker, final Message msg, final
Throwable t) {
         return true;
     }
+
+    @Override
+    public Level getLevel() {
+        return Level.ALL;
+    }
 }

Modified: logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/Logger.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/Logger.java?rev=1580752&r1=1580751&r2=1580752&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/Logger.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/Logger.java
Mon Mar 24 05:30:20 2014
@@ -95,14 +95,6 @@ public class Logger extends AbstractLogg
         }
     }
 
-    /**
-     * Returns the Level associated with the Logger.
-     * @return the Level associate with the Logger.
-     */
-    public Level getLevel() {
-        return config.level;
-    }
-
     @Override
     public void logMessage(final String fqcn, final Level level, final Marker marker, final
Message message, final Throwable t) {
         final Message msg = message == null ? new SimpleMessage("") : message;
@@ -177,6 +169,16 @@ public class Logger extends AbstractLogg
     }
 
     /**
+     * Gets the Level associated with the Logger.
+     * 
+     * @return the Level associate with the Logger.
+     */
+    @Override
+    public Level getLevel() {
+        return config.level;
+    }
+
+    /**
      * This method is not exposed through the public API and is used primarily for unit testing.
      * @return The number of Filters associated with the Logger.
      */

Modified: logging/log4j/log4j2/trunk/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLogger.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLogger.java?rev=1580752&r1=1580751&r2=1580752&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLogger.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLogger.java
Mon Mar 24 05:30:20 2014
@@ -22,6 +22,7 @@ import org.apache.logging.log4j.message.
 import org.apache.logging.log4j.message.Message;
 import org.apache.logging.log4j.message.MessageFactory;
 import org.apache.logging.log4j.spi.AbstractLogger;
+import org.slf4j.Logger;
 import org.slf4j.MarkerFactory;
 import org.slf4j.spi.LocationAwareLogger;
 
@@ -63,6 +64,28 @@ public class SLF4JLogger extends Abstrac
         }
     }
 
+    @Override
+    public Level getLevel() {
+        if (logger.isTraceEnabled()) {
+            return Level.TRACE;
+        }
+        if (logger.isDebugEnabled()) {
+            return Level.DEBUG;
+        }
+        if (logger.isInfoEnabled()) {
+            return Level.INFO;
+        }
+        if (logger.isWarnEnabled()) {
+            return Level.WARN;
+        }
+        if (logger.isErrorEnabled()) {
+            return Level.ERROR;
+        }
+        // Option: throw new IllegalStateException("Unknown SLF4JLevel");
+        // Option: return Level.ALL;
+        return Level.OFF;
+    }
+    
     public org.slf4j.Logger getLogger() {
         return locationAwareLogger != null ? locationAwareLogger : logger;
     }

Modified: logging/log4j/log4j2/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/src/changes/changes.xml?rev=1580752&r1=1580751&r2=1580752&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/src/changes/changes.xml (original)
+++ logging/log4j/log4j2/trunk/src/changes/changes.xml Mon Mar 24 05:30:20 2014
@@ -21,6 +21,9 @@
   </properties>
   <body>
     <release version="2.0-rc2?" date="2014-MM-DD" description="Bug fixes and enhancements">
+      <action issue="LOG4J2-576" dev="ggregory" type="add">
+          Add org.apache.logging.log4j.Logger.getLevel().
+      </action>
       <action issue="LOG4J2-574" dev="rpopma" type="update">
           Make Blocking the default WaitStrategy for Async Loggers.
       </action>



Mime
View raw message