directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From erodrig...@apache.org
Subject svn commit: r278616 - in /directory/protocol-providers/ntp/trunk: project.xml src/java/org/apache/ntp/protocol/NtpProtocolHandler.java
Date Sun, 04 Sep 2005 17:30:29 GMT
Author: erodriguez
Date: Sun Sep  4 10:30:25 2005
New Revision: 278616

URL: http://svn.apache.org/viewcvs?rev=278616&view=rev
Log:
Updated NTP protocol to use SLF4J logging.

Modified:
    directory/protocol-providers/ntp/trunk/project.xml
    directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/protocol/NtpProtocolHandler.java

Modified: directory/protocol-providers/ntp/trunk/project.xml
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/ntp/trunk/project.xml?rev=278616&r1=278615&r2=278616&view=diff
==============================================================================
--- directory/protocol-providers/ntp/trunk/project.xml (original)
+++ directory/protocol-providers/ntp/trunk/project.xml Sun Sep  4 10:30:25 2005
@@ -82,6 +82,12 @@
       <version>0.7.3-SNAPSHOT</version>
     </dependency>
     <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>nlog4j</artifactId>
+      <version>1.2.14</version>
+      <url>http://slf4j.org/nlog4j</url>
+    </dependency>
+    <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
       <version>3.8.1</version>

Modified: directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/protocol/NtpProtocolHandler.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/protocol/NtpProtocolHandler.java?rev=278616&r1=278615&r2=278616&view=diff
==============================================================================
--- directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/protocol/NtpProtocolHandler.java
(original)
+++ directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/protocol/NtpProtocolHandler.java
Sun Sep  4 10:30:25 2005
@@ -23,42 +23,61 @@
 import org.apache.ntp.NtpService;
 import org.apache.ntp.messages.NtpMessage;
 import org.apache.ntp.service.NtpServiceImpl;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class NtpProtocolHandler implements ProtocolHandler
 {
+    /** the log for this class */
+    private static final Logger log = LoggerFactory.getLogger( NtpProtocolHandler.class );
+
+    private NtpService ntpService = new NtpServiceImpl();
+
     public void sessionCreated( ProtocolSession session )
     {
-        System.out.println( session.getRemoteAddress() + " CREATED" );
+        if ( log.isDebugEnabled() )
+        {
+            log.debug( session.getRemoteAddress() + " CREATED" );
+        }
     }
 
     public void sessionOpened( ProtocolSession session )
     {
-        System.out.println( session.getRemoteAddress() + " OPENED" );
+        if ( log.isDebugEnabled() )
+        {
+            log.debug( session.getRemoteAddress() + " OPENED" );
+        }
     }
 
     public void sessionClosed( ProtocolSession session )
     {
-        System.out.println( session.getRemoteAddress() + " CLOSED" );
+        if ( log.isDebugEnabled() )
+        {
+            log.debug( session.getRemoteAddress() + " CLOSED" );
+        }
     }
 
     public void sessionIdle( ProtocolSession session, IdleStatus status )
     {
-        System.out.println( session.getRemoteAddress() + " IDLE(" + status + ")" );
+        if ( log.isDebugEnabled() )
+        {
+            log.debug( session.getRemoteAddress() + " IDLE(" + status + ")" );
+        }
     }
 
     public void exceptionCaught( ProtocolSession session, Throwable cause )
     {
-        System.out.println( session.getRemoteAddress() + " EXCEPTION" );
-        cause.printStackTrace( System.out );
-
+        log.error( session.getRemoteAddress() + " EXCEPTION", cause );
         session.close();
     }
 
     public void messageReceived( ProtocolSession session, Object message )
     {
-        System.out.println( session.getRemoteAddress() + " RCVD: " + message );
+        if ( log.isDebugEnabled() )
+        {
+            log.debug( session.getRemoteAddress() + " RCVD: " + message );
+        }
 
-        NtpService ntpService = new NtpServiceImpl();
         NtpMessage reply = ntpService.getReplyFor( (NtpMessage) message );
 
         session.write( reply );
@@ -66,6 +85,9 @@
 
     public void messageSent( ProtocolSession session, Object message )
     {
-        System.out.println( session.getRemoteAddress() + " SENT: " + message );
+        if ( log.isDebugEnabled() )
+        {
+            log.debug( session.getRemoteAddress() + " SENT: " + message );
+        }
     }
 }



Mime
View raw message