< Previous by Date Date Index Next by Date >
< Previous in Thread Thread Index Next in Thread >

[reSIProcate] Transport logging patch


Hi,
please ignore previous patch, it has small mistake.
Here is a new one.

Sincerely, tez.
diff --git resip/stack/Transport.cxx resip/stack/Transport.cxx
index e11f3a0..cc0fe23 100644
--- resip/stack/Transport.cxx
+++ resip/stack/Transport.cxx
@@ -381,6 +381,11 @@ Transport::stampReceived(SipMessage* message)
    }
    DebugLog (<< "incoming from: " << message->getSource());
    StackLog (<< endl << endl << *message);
+
+   if( getTransportLoggingDecorator() )
+   {
+      getTransportLoggingDecorator()->print( *message );
+   }
 }
 
 
@@ -453,6 +458,13 @@ resip::operator<<(EncodeStream& strm, const resip::Transport& rhs)
    return strm;
 }
 
+Transport::TransportLoggingDecorator* Transport::getTransportLoggingDecorator()
+{
+   return 0 != mLogDecorator.get() ? mLogDecorator.get() : 0;
+}
+
+SharedPtr<Transport::TransportLoggingDecorator> Transport::mLogDecorator;
+
 /* ====================================================================
  * The Vovida Software License, Version 1.0
  *
diff --git resip/stack/Transport.hxx resip/stack/Transport.hxx
index d2573d3..930b6ed 100644
--- resip/stack/Transport.hxx
+++ resip/stack/Transport.hxx
@@ -10,7 +10,7 @@
 #include "resip/stack/NameAddr.hxx"
 #include "resip/stack/Compression.hxx"
 #include "resip/stack/SendData.hxx"
-
+#include "rutil/SharedPtr.hxx"
 namespace resip
 {
 
@@ -72,6 +72,16 @@ class FdPollGrp;
 class Transport : public FdSetIOObserver
 {
    public:
+    class TransportLoggingDecorator
+      {
+      public:
+          virtual ~TransportLoggingDecorator(){}
+          virtual void print( SipMessage &msg, const Tuple &source, const Tuple &destination ) = 0;
+          virtual void print( SipMessage &msg ) = 0;
+      };
+
+      static TransportLoggingDecorator* getTransportLoggingDecorator();
+      static void setTransportLoggingDecorator( resip::SharedPtr<TransportLoggingDecorator> d ){ mLogDecorator = d;  }
 
   
       /**
@@ -374,6 +384,7 @@ class Transport : public FdSetIOObserver
       friend EncodeStream& operator<<(EncodeStream& strm, const Transport& rhs);
 
       Data mTlsDomain;
+      static resip::SharedPtr<TransportLoggingDecorator> mLogDecorator;
    protected:
       AfterSocketCreationFuncPtr mSocketFunc;
       Compression &mCompression;
diff --git resip/stack/TransportSelector.cxx resip/stack/TransportSelector.cxx
index 62295d5..b3bf0ce 100644
--- resip/stack/TransportSelector.cxx
+++ resip/stack/TransportSelector.cxx
@@ -1153,9 +1153,15 @@ TransportSelector::transmit(SipMessage* msg, Tuple& target, SendData* sendData)
 
          // Call back anyone who wants to perform outbound decoration
          msg->callOutboundDecorators(source, target,remoteSigcompId);
+         Transport::TransportLoggingDecorator* d = Transport::getTransportLoggingDecorator();
 
-         std::auto_ptr<SendData> send(new SendData(target, 
-                                                   resip::Data::Empty, 
+         if( d )
+         {
+            d->print( *msg, source, target );
+         }
+
+         std::auto_ptr<SendData> send(new SendData(target,
+                                                   resip::Data::Empty,
                                                    msg->getTransactionId(),
                                                    remoteSigcompId));