directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r387423 - in /directory/trunks/mina/core/src/main/java/org/apache/mina: common/support/DefaultExceptionMonitor.java filter/LoggingFilter.java util/SessionLog.java
Date Tue, 21 Mar 2006 05:34:47 GMT
Author: trustin
Date: Mon Mar 20 21:34:44 2006
New Revision: 387423

URL: http://svn.apache.org/viewcvs?rev=387423&view=rev
Log:
Related issue: DIRMINA-193 (Logger improvement)
* LoggingFilter and DefaultExceptionMonitor don't create messages when a level is disabled.
* Changed static loggers into non-static where possible.


Modified:
    directory/trunks/mina/core/src/main/java/org/apache/mina/common/support/DefaultExceptionMonitor.java
    directory/trunks/mina/core/src/main/java/org/apache/mina/filter/LoggingFilter.java
    directory/trunks/mina/core/src/main/java/org/apache/mina/util/SessionLog.java

Modified: directory/trunks/mina/core/src/main/java/org/apache/mina/common/support/DefaultExceptionMonitor.java
URL: http://svn.apache.org/viewcvs/directory/trunks/mina/core/src/main/java/org/apache/mina/common/support/DefaultExceptionMonitor.java?rev=387423&r1=387422&r2=387423&view=diff
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/common/support/DefaultExceptionMonitor.java
(original)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/common/support/DefaultExceptionMonitor.java
Mon Mar 20 21:34:44 2006
@@ -35,10 +35,13 @@
  */
 public class DefaultExceptionMonitor extends ExceptionMonitor
 {
-    private static final Logger log = LoggerFactory.getLogger( DefaultExceptionMonitor.class
);
+    private final Logger log = LoggerFactory.getLogger( DefaultExceptionMonitor.class );
 
     public void exceptionCaught( Throwable cause )
     {
-        log.warn( "Unexpected exception.", cause );
+        if( log.isWarnEnabled() )
+        {
+            log.warn( "Unexpected exception.", cause );
+        }
     }
 }

Modified: directory/trunks/mina/core/src/main/java/org/apache/mina/filter/LoggingFilter.java
URL: http://svn.apache.org/viewcvs/directory/trunks/mina/core/src/main/java/org/apache/mina/filter/LoggingFilter.java?rev=387423&r1=387422&r2=387423&view=diff
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/filter/LoggingFilter.java (original)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/filter/LoggingFilter.java Mon
Mar 20 21:34:44 2006
@@ -70,31 +70,46 @@
 
     public void sessionIdle( NextFilter nextFilter, IoSession session, IdleStatus status
)
     {
-        SessionLog.info( session, "IDLE: " + status );
+        if( SessionLog.isInfoEnabled( session ) )
+        {
+            SessionLog.info( session, "IDLE: " + status );
+        }
         nextFilter.sessionIdle( session, status );
     }
 
     public void exceptionCaught( NextFilter nextFilter, IoSession session, Throwable cause
)
     {
-        SessionLog.error( session, "EXCEPTION:", cause );
+        if( SessionLog.isInfoEnabled( session ) )
+        {
+            SessionLog.error( session, "EXCEPTION:", cause );
+        }
         nextFilter.exceptionCaught( session, cause );
     }
 
     public void messageReceived( NextFilter nextFilter, IoSession session, Object message
)
     {
-        SessionLog.info( session, "RECEIVED: " + message );
+        if( SessionLog.isInfoEnabled( session ) )
+        {
+            SessionLog.info( session, "RECEIVED: " + message );
+        }
         nextFilter.messageReceived( session, message );
     }
 
     public void messageSent( NextFilter nextFilter, IoSession session, Object message )
     {
-        SessionLog.info( session, "SENT: " + message );
+        if( SessionLog.isInfoEnabled( session ) )
+        {
+            SessionLog.info( session, "SENT: " + message );
+        }
         nextFilter.messageSent( session, message );
     }
 
     public void filterWrite( NextFilter nextFilter, IoSession session, WriteRequest writeRequest
)
     {
-        SessionLog.info( session, "WRITE: " + writeRequest );
+        if( SessionLog.isInfoEnabled( session ) )
+        {
+            SessionLog.info( session, "WRITE: " + writeRequest );
+        }
         nextFilter.filterWrite( session, writeRequest );
     }
 

Modified: directory/trunks/mina/core/src/main/java/org/apache/mina/util/SessionLog.java
URL: http://svn.apache.org/viewcvs/directory/trunks/mina/core/src/main/java/org/apache/mina/util/SessionLog.java?rev=387423&r1=387422&r2=387423&view=diff
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/util/SessionLog.java (original)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/util/SessionLog.java Mon Mar
20 21:34:44 2006
@@ -142,7 +142,7 @@
 
     private static Logger getLogger( IoSession session )
     {
-        Logger log = (Logger) session.getAttribute( LOGGER );
+        Logger log = ( Logger ) session.getAttribute( LOGGER );
         if( log == null )
         {
             log = LoggerFactory.getLogger( getClass( session ) );
@@ -152,10 +152,10 @@
                 prefix = "[" + session.getRemoteAddress() + "] ";
                 session.setAttribute( PREFIX, prefix );
             }
-                
+
             session.setAttribute( LOGGER, log );
         }
-        
+
         return log;
     }
 }



Mime
View raw message