labs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ber...@apache.org
Subject svn commit: r709938 - in /labs/vysper: ./ log/ src/main/config/ src/main/java/org/apache/vysper/mina/codec/ src/main/java/org/apache/vysper/xmpp/protocol/ src/main/java/org/apache/vysper/xmpp/stanza/
Date Sun, 02 Nov 2008 21:26:11 GMT
Author: berndf
Date: Sun Nov  2 13:26:10 2008
New Revision: 709938

URL: http://svn.apache.org/viewvc?rev=709938&view=rev
Log:
[vysper] make some classes logging friendly (add toString()), add dedicated stanza log, add
logging libs to build.xml

Added:
    labs/vysper/log/
Modified:
    labs/vysper/build.xml
    labs/vysper/src/main/config/log4j.xml
    labs/vysper/src/main/java/org/apache/vysper/mina/codec/StanzaWriteInfo.java
    labs/vysper/src/main/java/org/apache/vysper/mina/codec/StanzaWriterProtocolEncoder.java
    labs/vysper/src/main/java/org/apache/vysper/mina/codec/XMLStreamTokenizer.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/protocol/StanzaHandler.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/stanza/Stanza.java

Modified: labs/vysper/build.xml
URL: http://svn.apache.org/viewvc/labs/vysper/build.xml?rev=709938&r1=709937&r2=709938&view=diff
==============================================================================
--- labs/vysper/build.xml (original)
+++ labs/vysper/build.xml Sun Nov  2 13:26:10 2008
@@ -85,7 +85,8 @@
     <pathelement location="${basedir}/lib/smack.jar"/>
     <pathelement location="${basedir}/lib/smackx.jar"/>
     <pathelement location="${basedir}/lib/log4j-1.2.14.jar"/>
-    <pathelement location="${basedir}/lib/slf4j-log4j12-1.0.1.jar"/>
+    <pathelement location="${basedir}/lib/slf4j-api-1.5.3.jar"/>
+    <pathelement location="${basedir}/lib/slf4j-log4j12-1.5.3.jar"/>
   </path>
   
   <patternset id="excluded.from.vysper">

Modified: labs/vysper/src/main/config/log4j.xml
URL: http://svn.apache.org/viewvc/labs/vysper/src/main/config/log4j.xml?rev=709938&r1=709937&r2=709938&view=diff
==============================================================================
--- labs/vysper/src/main/config/log4j.xml (original)
+++ labs/vysper/src/main/config/log4j.xml Sun Nov  2 13:26:10 2008
@@ -25,7 +25,7 @@
       <param name="Threshold" value="TRACE"/>
 
       <layout class="org.apache.log4j.PatternLayout">
-         <param name="ConversionPattern" value="%-5p %d{HH:mm:ss,SSS} | %c{1} | %m%n"/>
+          <param name="ConversionPattern" value="%d{HH:mm:ss,SSS} | %-5p | %c | %m%n"/>
       </layout>
    </appender>
 
@@ -37,6 +37,18 @@
      <param name="Threshold" value="INFO"/>
 
      <layout class="org.apache.log4j.PatternLayout">
+       <param name="ConversionPattern" value="%d{HH:mm:ss,SSS} | %-5p | %c | %m%n"/>
+     </layout>
+   </appender>
+
+   <appender name="STANZA" class="org.apache.log4j.RollingFileAppender">
+     <param name="File" value="log/stanza.log"/>
+     <param name="Append" value="true"/>
+     <param name="MaxFileSize" value="500KB"/>
+     <param name="MaxBackupIndex" value="1"/>
+     <param name="Threshold" value="INFO"/>
+
+     <layout class="org.apache.log4j.PatternLayout">
        <param name="ConversionPattern" value="%-5p %d{HH:mm:ss,SSS} | %c{1} | %m%n"/>
      </layout>
    </appender>
@@ -46,6 +58,19 @@
      <priority value="INFO"/>
    </category>
 
+   <!-- limit logging for mina -->
+   <category name="org.apache.mina">
+     <priority value="INFO"/>
+   </category>
+   <category name="org.apache.vysper.mina">
+     <priority value="INFO"/>
+   </category>
+
+   <category name="stanza">
+     <priority value="INFO"/>
+     <appender-ref ref="STANZA" />  
+   </category>
+
    <root>
      <appender-ref ref="CONS"/>
      <appender-ref ref="FILE"/>

Modified: labs/vysper/src/main/java/org/apache/vysper/mina/codec/StanzaWriteInfo.java
URL: http://svn.apache.org/viewvc/labs/vysper/src/main/java/org/apache/vysper/mina/codec/StanzaWriteInfo.java?rev=709938&r1=709937&r2=709938&view=diff
==============================================================================
--- labs/vysper/src/main/java/org/apache/vysper/mina/codec/StanzaWriteInfo.java (original)
+++ labs/vysper/src/main/java/org/apache/vysper/mina/codec/StanzaWriteInfo.java Sun Nov  2
13:26:10 2008
@@ -17,6 +17,7 @@
 package org.apache.vysper.mina.codec;
 
 import org.apache.vysper.xmpp.stanza.Stanza;
+import org.apache.vysper.xmpp.writer.DenseStanzaLogRenderer;
 
 /**
  * a stanza plus the flags indicating which parts of the stanza are actually to be written.
@@ -58,4 +59,16 @@
     public boolean isWriteClosingElement() {
         return writeClosingElement;
     }
+
+    @Override
+    public String toString() {
+        StringBuilder stringBuilder = new StringBuilder();
+        stringBuilder.append("[ prolog=").append(writeProlog);
+        stringBuilder.append(", open=").append(writeOpeningElement);
+        stringBuilder.append(", close=").append(writeClosingElement);
+        stringBuilder.append(", content=").append(writeContent);
+        stringBuilder.append(", stanza=[").append(DenseStanzaLogRenderer.render(stanza));
+        stringBuilder.append("]");
+        return stringBuilder.toString();
+    }
 }

Modified: labs/vysper/src/main/java/org/apache/vysper/mina/codec/StanzaWriterProtocolEncoder.java
URL: http://svn.apache.org/viewvc/labs/vysper/src/main/java/org/apache/vysper/mina/codec/StanzaWriterProtocolEncoder.java?rev=709938&r1=709937&r2=709938&view=diff
==============================================================================
--- labs/vysper/src/main/java/org/apache/vysper/mina/codec/StanzaWriterProtocolEncoder.java
(original)
+++ labs/vysper/src/main/java/org/apache/vysper/mina/codec/StanzaWriterProtocolEncoder.java
Sun Nov  2 13:26:10 2008
@@ -25,6 +25,8 @@
 import org.apache.vysper.xmpp.writer.DenseStanzaLogRenderer;
 import org.apache.vysper.xmpp.writer.StanzaWriter;
 import org.apache.vysper.xmpp.xmlfragment.Renderer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import java.nio.charset.CharsetEncoder;
 
@@ -33,6 +35,8 @@
  */
 public class StanzaWriterProtocolEncoder implements ProtocolEncoder {
 
+    final Logger serverStanzaLogger = LoggerFactory.getLogger("stanza.server");
+
     public void encode(IoSession ioSession, Object o, ProtocolEncoderOutput protocolEncoderOutput)
throws Exception {
         if (!(o instanceof StanzaWriteInfo)) {
             throw new IllegalArgumentException("StanzaWriterProtocolEncoder only handles
StanzaWriteInfo objects");
@@ -42,7 +46,7 @@
         Stanza element = stanzaWriteInfo.getStanza();
         Renderer renderer = new Renderer(element);
 
-        System.out.println("S: " + DenseStanzaLogRenderer.render(element));
+        serverStanzaLogger.info(DenseStanzaLogRenderer.render(element));
 
         ByteBuffer byteBuffer = ByteBuffer.allocate(16).setAutoExpand(true);
         if (stanzaWriteInfo.isWriteProlog()) byteBuffer.putString(StanzaWriter.XML_PROLOG,
getSessionEncoder());

Modified: labs/vysper/src/main/java/org/apache/vysper/mina/codec/XMLStreamTokenizer.java
URL: http://svn.apache.org/viewvc/labs/vysper/src/main/java/org/apache/vysper/mina/codec/XMLStreamTokenizer.java?rev=709938&r1=709937&r2=709938&view=diff
==============================================================================
--- labs/vysper/src/main/java/org/apache/vysper/mina/codec/XMLStreamTokenizer.java (original)
+++ labs/vysper/src/main/java/org/apache/vysper/mina/codec/XMLStreamTokenizer.java Sun Nov
 2 13:26:10 2008
@@ -28,6 +28,8 @@
 import org.apache.vysper.xmpp.xmldecoder.XMLRawToFragementConverter;
 import org.apache.vysper.xmpp.xmlfragment.XMLElement;
 import org.apache.vysper.xmpp.xmlfragment.XMLFragment;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -40,6 +42,8 @@
     public static final String SESSION_ATTRIBUTE_NAME = "tokenizerParticleList";
     private static final XMLRawToFragementConverter CONVERTER = new XMLRawToFragementConverter();
 
+    final Logger clientStanzaLogger = LoggerFactory.getLogger("stanza.client");
+
     @Override
     public boolean doDecode(IoSession ioSession, ByteBuffer byteBuffer, ProtocolDecoderOutput
protocolDecoderOutput) throws Exception {
 
@@ -69,7 +73,7 @@
                         // propagate element
 
                         XMLElement element = (XMLElement) xmlFragment;
-                        System.out.println("C: " + DenseStanzaLogRenderer.render(element));
+                        clientStanzaLogger.info(DenseStanzaLogRenderer.render(element));
                         protocolDecoderOutput.write(element);
                     } else {
                         // TODO handle text elements properly might be only whitespaces/newlines

Modified: labs/vysper/src/main/java/org/apache/vysper/xmpp/protocol/StanzaHandler.java
URL: http://svn.apache.org/viewvc/labs/vysper/src/main/java/org/apache/vysper/xmpp/protocol/StanzaHandler.java?rev=709938&r1=709937&r2=709938&view=diff
==============================================================================
--- labs/vysper/src/main/java/org/apache/vysper/xmpp/protocol/StanzaHandler.java (original)
+++ labs/vysper/src/main/java/org/apache/vysper/xmpp/protocol/StanzaHandler.java Sun Nov 
2 13:26:10 2008
@@ -21,8 +21,9 @@
 import org.apache.vysper.xmpp.stanza.Stanza;
 
 /**
- * while stanzas hold the raw information read from stream its handler holds the logic for
- * interpreting its semantics and execution. essentially, this is "the command".
+ * While stanzas hold the raw information read from stream, its handler holds the logic for
+ * interpreting its semantics and execution. If stanzas are commands, a StanzaHandler is
a command processor.
+ * It is very much comparable to a Servlet. 
  * StanzaHandler implementations must be stateless!
  */
 public interface StanzaHandler {

Modified: labs/vysper/src/main/java/org/apache/vysper/xmpp/stanza/Stanza.java
URL: http://svn.apache.org/viewvc/labs/vysper/src/main/java/org/apache/vysper/xmpp/stanza/Stanza.java?rev=709938&r1=709937&r2=709938&view=diff
==============================================================================
--- labs/vysper/src/main/java/org/apache/vysper/xmpp/stanza/Stanza.java (original)
+++ labs/vysper/src/main/java/org/apache/vysper/xmpp/stanza/Stanza.java Sun Nov  2 13:26:10
2008
@@ -23,6 +23,7 @@
 import org.apache.vysper.xmpp.addressing.Entity;
 import org.apache.vysper.xmpp.addressing.EntityImpl;
 import org.apache.vysper.xmpp.addressing.EntityFormatException;
+import org.apache.vysper.xmpp.writer.DenseStanzaLogRenderer;
 
 import java.util.List;
 
@@ -70,4 +71,9 @@
         }
         return entity;
     }
+
+    @Override
+    public String toString() {
+        return DenseStanzaLogRenderer.render(this);
+    }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@labs.apache.org
For additional commands, e-mail: commits-help@labs.apache.org


Mime
View raw message