geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r699433 - in /geronimo/gshell/trunk/gshell-remote/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper: stream/SessionInputStream.java stream/SessionOutputStream.java transport/base/BaseService.java transport/base/LoggingFilter.java
Date Fri, 26 Sep 2008 17:50:08 GMT
Author: jdillon
Date: Fri Sep 26 10:50:07 2008
New Revision: 699433

URL: http://svn.apache.org/viewvc?rev=699433&view=rev
Log:
Add custom LoggingFilter to set the right levels
Clean up some remote session logging

Added:
    geronimo/gshell/trunk/gshell-remote/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/base/LoggingFilter.java
  (with props)
Modified:
    geronimo/gshell/trunk/gshell-remote/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/stream/SessionInputStream.java
    geronimo/gshell/trunk/gshell-remote/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/stream/SessionOutputStream.java
    geronimo/gshell/trunk/gshell-remote/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/base/BaseService.java

Modified: geronimo/gshell/trunk/gshell-remote/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/stream/SessionInputStream.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-remote/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/stream/SessionInputStream.java?rev=699433&r1=699432&r2=699433&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-remote/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/stream/SessionInputStream.java
(original)
+++ geronimo/gshell/trunk/gshell-remote/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/stream/SessionInputStream.java
Fri Sep 26 10:50:07 2008
@@ -168,7 +168,7 @@
 
             ByteBuffer src = msg.getBuffer();
 
-            log.debug("Writing {} bytes", src.remaining());
+            log.trace("Writing {} bytes", src.remaining());
 
             if (buff.hasRemaining()) {
                 buff.compact();

Modified: geronimo/gshell/trunk/gshell-remote/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/stream/SessionOutputStream.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-remote/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/stream/SessionOutputStream.java?rev=699433&r1=699432&r2=699433&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-remote/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/stream/SessionOutputStream.java
(original)
+++ geronimo/gshell/trunk/gshell-remote/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/stream/SessionOutputStream.java
Fri Sep 26 10:50:07 2008
@@ -100,7 +100,7 @@
     private synchronized void write(final ByteBuffer buff) throws IOException {
         ensureOpened();
 
-        log.debug("Writing {} bytes", buff.remaining());
+        log.trace("Writing {} bytes", buff.remaining());
 
         WriteFuture wf = session.write(new StreamMessage(buff));
 

Modified: geronimo/gshell/trunk/gshell-remote/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/base/BaseService.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-remote/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/base/BaseService.java?rev=699433&r1=699432&r2=699433&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-remote/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/base/BaseService.java
(original)
+++ geronimo/gshell/trunk/gshell-remote/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/base/BaseService.java
Fri Sep 26 10:50:07 2008
@@ -36,7 +36,6 @@
 import org.apache.mina.common.IoSession;
 import org.apache.mina.common.SimpleByteBufferAllocator;
 import org.apache.mina.common.ThreadModel;
-import org.apache.mina.filter.LoggingFilter;
 import org.apache.mina.filter.codec.ProtocolCodecFilter;
 import org.apache.mina.filter.codec.serialization.ObjectSerializationCodecFactory;
 import org.slf4j.Logger;
@@ -179,10 +178,6 @@
 
         chain.addLast(ProtocolCodecFilter.class.getSimpleName(), new ProtocolCodecFilter(new
ObjectSerializationCodecFactory()));
 
-        //
-        // FIXME: Need to create a custom LoggingFilter which logs things as debug and trace,
not info, PITA
-        //
-        
         chain.addLast(LoggingFilter.class.getSimpleName(), new LoggingFilter());
 
         chain.addLast(SessionStreamFilter.class.getSimpleName(), new SessionStreamFilter());

Added: geronimo/gshell/trunk/gshell-remote/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/base/LoggingFilter.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-remote/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/base/LoggingFilter.java?rev=699433&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-remote/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/base/LoggingFilter.java
(added)
+++ geronimo/gshell/trunk/gshell-remote/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/base/LoggingFilter.java
Fri Sep 26 10:50:07 2008
@@ -0,0 +1,175 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.gshell.whisper.transport.base;
+
+import org.apache.geronimo.gshell.whisper.util.SessionAttributeBinder;
+import org.apache.mina.common.IdleStatus;
+import org.apache.mina.common.IoFilterAdapter;
+import org.apache.mina.common.IoSession;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Logs all MINA protocol events to a {@link Logger}.
+ *
+ * @version $Rev$ $Date$
+ */
+public class LoggingFilter
+    extends IoFilterAdapter
+{
+    private static final SessionAttributeBinder<Logger> LOGGER_BINDER = new SessionAttributeBinder<Logger>(LoggingFilter.class,
"logger");
+
+    private static final SessionAttributeBinder<String> PREFIX_BINDER = new SessionAttributeBinder<String>(LoggingFilter.class,
"prefix");
+
+    private Logger getLogger(final IoSession session) {
+        assert session != null;
+
+        Logger logger;
+
+        try {
+            logger = LOGGER_BINDER.lookup(session);
+        }
+        catch (SessionAttributeBinder.NotBoundException e) {
+            logger = LoggerFactory.getLogger(session.getHandler().getClass());
+
+            if (!PREFIX_BINDER.isBound(session)) {
+                String prefix = "[" + session.getRemoteAddress() + "]";
+                PREFIX_BINDER.bind(session, prefix);
+            }
+
+            LOGGER_BINDER.bind(session, logger);
+        }
+
+        return logger;
+    }
+
+    public void sessionCreated(final NextFilter nextFilter, final IoSession session) {
+        assert nextFilter != null;
+        assert session != null;
+
+        Logger log = getLogger(session);
+        if (log.isDebugEnabled()) {
+            log.debug("{} {}", PREFIX_BINDER.lookup(session), "CREATED");
+        }
+
+        nextFilter.sessionCreated(session);
+    }
+
+    public void sessionOpened(final NextFilter nextFilter, final IoSession session) {
+        assert nextFilter != null;
+        assert session != null;
+
+        Logger log = getLogger(session);
+        if (log.isDebugEnabled()) {
+            log.debug("{} {}", PREFIX_BINDER.lookup(session), "OPENED");
+        }
+
+        nextFilter.sessionOpened(session);
+    }
+
+    public void sessionClosed(final NextFilter nextFilter, final IoSession session) {
+        assert nextFilter != null;
+        assert session != null;
+
+        Logger log = getLogger(session);
+        if (log.isDebugEnabled()) {
+            log.debug("{} {}", PREFIX_BINDER.lookup(session), "CLOSED");
+        }
+
+        nextFilter.sessionClosed(session);
+    }
+
+    public void sessionIdle(final NextFilter nextFilter, final IoSession session, final IdleStatus
status) {
+        assert nextFilter != null;
+        assert session != null;
+        assert status != null;
+
+        Logger log = getLogger(session);
+        if (log.isTraceEnabled()) {
+            log.trace("{} {}: {}", new Object[] { PREFIX_BINDER.lookup(session), "IDLE",
status });
+        }
+
+        nextFilter.sessionIdle(session, status);
+    }
+
+    public void exceptionCaught(final NextFilter nextFilter, final IoSession session, final
Throwable cause) {
+        assert nextFilter != null;
+        assert session != null;
+        assert cause != null;
+
+        Logger log = getLogger(session);
+        if (log.isWarnEnabled()) {
+            log.warn(PREFIX_BINDER.lookup(session) + " EXCEPTION: " + cause, cause);
+        }
+
+        nextFilter.exceptionCaught(session, cause);
+    }
+
+    public void messageReceived(final NextFilter nextFilter, final IoSession session, final
Object message) {
+        assert nextFilter != null;
+        assert session != null;
+        assert message != null;
+
+        Logger log = getLogger(session);
+        if (log.isTraceEnabled()) {
+            log.trace("{} {}: {}", new Object[] { PREFIX_BINDER.lookup(session), "RECEIVED",
message });
+        }
+
+        nextFilter.messageReceived(session, message);
+    }
+
+    public void messageSent(final NextFilter nextFilter, final IoSession session, final Object
message) {
+        assert nextFilter != null;
+        assert session != null;
+        assert message != null;
+
+        Logger log = getLogger(session);
+        if (log.isTraceEnabled()) {
+            log.trace("{} {}: {}", new Object[] { PREFIX_BINDER.lookup(session), "SENT",
message });
+        }
+
+        nextFilter.messageSent(session, message);
+    }
+
+    public void filterWrite(final NextFilter nextFilter, final IoSession session, final WriteRequest
writeRequest) {
+        assert nextFilter != null;
+        assert session != null;
+        assert writeRequest != null;
+
+        Logger log = getLogger(session);
+        if (log.isTraceEnabled()) {
+            log.trace("{} {}: {}", new Object[] { PREFIX_BINDER.lookup(session), "WRITE",
writeRequest });
+        }
+
+        nextFilter.filterWrite(session, writeRequest);
+    }
+
+    public void filterClose(final NextFilter nextFilter, final IoSession session) throws
Exception {
+        assert nextFilter != null;
+        assert session != null;
+
+        Logger log = getLogger(session);
+        if (log.isDebugEnabled()) {
+            log.debug("{} {}", PREFIX_BINDER.lookup(session), "CLOSE");
+        }
+
+        nextFilter.filterClose(session);
+    }
+}

Propchange: geronimo/gshell/trunk/gshell-remote/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/base/LoggingFilter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gshell/trunk/gshell-remote/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/base/LoggingFilter.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/gshell/trunk/gshell-remote/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/base/LoggingFilter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message