qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From g...@apache.org
Subject svn commit: r1548177 - in /qpid/trunk/qpid/cpp/src: amqp.cmake config.h.cmake qpid/broker/amqp/Connection.cpp qpid/broker/amqp/Connection.h qpid/messaging/amqp/ConnectionContext.cpp qpid/messaging/amqp/ConnectionContext.h
Date Thu, 05 Dec 2013 15:53:53 GMT
Author: gsim
Date: Thu Dec  5 15:53:52 2013
New Revision: 1548177

URL: http://svn.apache.org/r1548177
Log:
QPID-5395: use newly added proton tracer callback to unify logging

Modified:
    qpid/trunk/qpid/cpp/src/amqp.cmake
    qpid/trunk/qpid/cpp/src/config.h.cmake
    qpid/trunk/qpid/cpp/src/qpid/broker/amqp/Connection.cpp
    qpid/trunk/qpid/cpp/src/qpid/broker/amqp/Connection.h
    qpid/trunk/qpid/cpp/src/qpid/messaging/amqp/ConnectionContext.cpp
    qpid/trunk/qpid/cpp/src/qpid/messaging/amqp/ConnectionContext.h

Modified: qpid/trunk/qpid/cpp/src/amqp.cmake
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/amqp.cmake?rev=1548177&r1=1548176&r2=1548177&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/amqp.cmake (original)
+++ qpid/trunk/qpid/cpp/src/amqp.cmake Thu Dec  5 15:53:52 2013
@@ -58,6 +58,10 @@ if (PROTON_FOUND)
         else (PROTON_VERSION GREATER ${maximum_version})
             message(STATUS "Qpid proton found, amqp 1.0 support enabled")
             set (amqp_default ON)
+            #remove when 0.5 no longer supported
+            if (NOT PROTON_VERSION EQUAL 0.5)
+               set (HAVE_PROTON_TRACER 1)
+            endif (NOT PROTON_VERSION EQUAL 0.5)
         endif (PROTON_VERSION GREATER ${maximum_version})
     endif (PROTON_VERSION LESS ${minimum_version})
 else (PROTON_FOUND)

Modified: qpid/trunk/qpid/cpp/src/config.h.cmake
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/config.h.cmake?rev=1548177&r1=1548176&r2=1548177&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/config.h.cmake (original)
+++ qpid/trunk/qpid/cpp/src/config.h.cmake Thu Dec  5 15:53:52 2013
@@ -61,5 +61,6 @@
 #cmakedefine HAVE_SYS_SDT_H ${HAVE_SYS_SDT_H}
 #cmakedefine HAVE_LOG_AUTHPRIV
 #cmakedefine HAVE_LOG_FTP
+#cmakedefine HAVE_PROTON_TRACER
 
 #endif /* QPID_CONFIG_H */

Modified: qpid/trunk/qpid/cpp/src/qpid/broker/amqp/Connection.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/broker/amqp/Connection.cpp?rev=1548177&r1=1548176&r2=1548177&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/broker/amqp/Connection.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/broker/amqp/Connection.cpp Thu Dec  5 15:53:52 2013
@@ -30,6 +30,7 @@
 #include "qpid/framing/ProtocolVersion.h"
 #include "qpid/log/Statement.h"
 #include "qpid/sys/OutputControl.h"
+#include "config.h"
 #include <sstream>
 extern "C" {
 #include <proton/engine.h>
@@ -39,6 +40,31 @@ extern "C" {
 namespace qpid {
 namespace broker {
 namespace amqp {
+namespace {
+//remove conditional when 0.5 is no longer supported
+#ifdef HAVE_PROTON_TRACER
+void do_trace(pn_transport_t* transport, const char* message)
+{
+    Connection* c = reinterpret_cast<Connection*>(pn_transport_get_context(transport));
+    if (c) c->trace(message);
+}
+
+void set_tracer(pn_transport_t* transport, void* context)
+{
+    pn_transport_set_context(transport, context);
+    pn_transport_set_tracer(transport, &do_trace);
+}
+#else
+void set_tracer(pn_transport_t*, void*)
+{
+}
+#endif
+}
+
+void Connection::trace(const char* message) const
+{
+    QPID_LOG_CAT(trace, protocol, "[" << id << "]: " << message);
+}
 
 Connection::Connection(qpid::sys::OutputControl& o, const std::string& i, BrokerContext&
b, bool saslInUse)
     : BrokerContext(b), ManagedConnection(getBroker(), i),
@@ -53,7 +79,10 @@ Connection::Connection(qpid::sys::Output
     out.activateOutput();
     bool enableTrace(false);
     QPID_LOG_TEST_CAT(trace, protocol, enableTrace);
-    if (enableTrace) pn_transport_trace(transport, PN_TRACE_FRM);
+    if (enableTrace) {
+        pn_transport_trace(transport, PN_TRACE_FRM);
+        set_tracer(transport, this);
+    }
 
     getBroker().getConnectionObservers().connection(*this);
     if (!saslInUse) {

Modified: qpid/trunk/qpid/cpp/src/qpid/broker/amqp/Connection.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/broker/amqp/Connection.h?rev=1548177&r1=1548176&r2=1548177&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/broker/amqp/Connection.h (original)
+++ qpid/trunk/qpid/cpp/src/qpid/broker/amqp/Connection.h Thu Dec  5 15:53:52 2013
@@ -59,6 +59,7 @@ class Connection : public BrokerContext,
     pn_transport_t* getTransport();
     void setUserId(const std::string&);
     void abort();
+    void trace(const char*) const;
   protected:
     typedef std::map<pn_session_t*, boost::shared_ptr<Session> > Sessions;
     pn_connection_t* connection;

Modified: qpid/trunk/qpid/cpp/src/qpid/messaging/amqp/ConnectionContext.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/messaging/amqp/ConnectionContext.cpp?rev=1548177&r1=1548176&r2=1548177&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/messaging/amqp/ConnectionContext.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/messaging/amqp/ConnectionContext.cpp Thu Dec  5 15:53:52
2013
@@ -37,6 +37,7 @@
 #include "qpid/sys/SecurityLayer.h"
 #include "qpid/sys/SystemInfo.h"
 #include "qpid/sys/Time.h"
+#include "config.h"
 #include <vector>
 extern "C" {
 #include <proton/engine.h>
@@ -45,6 +46,31 @@ extern "C" {
 namespace qpid {
 namespace messaging {
 namespace amqp {
+namespace {
+//remove conditional when 0.5 is no longer supported
+#ifdef HAVE_PROTON_TRACER
+void do_trace(pn_transport_t* transport, const char* message)
+{
+    ConnectionContext* c = reinterpret_cast<ConnectionContext*>(pn_transport_get_context(transport));
+    if (c) c->trace(message);
+}
+
+void set_tracer(pn_transport_t* transport, void* context)
+{
+    pn_transport_set_context(transport, context);
+    pn_transport_set_tracer(transport, &do_trace);
+}
+#else
+void set_tracer(pn_transport_t*, void*)
+{
+}
+#endif
+}
+
+void ConnectionContext::trace(const char* message) const
+{
+    QPID_LOG_CAT(trace, protocol, "[" << identifier << "]: " << message);
+}
 
 ConnectionContext::ConnectionContext(const std::string& url, const qpid::types::Variant::Map&
o)
     : qpid::messaging::ConnectionOptions(o),
@@ -67,7 +93,10 @@ ConnectionContext::ConnectionContext(con
     pn_connection_set_container(connection, identifier.c_str());
     bool enableTrace(false);
     QPID_LOG_TEST_CAT(trace, protocol, enableTrace);
-    if (enableTrace) pn_transport_trace(engine, PN_TRACE_FRM);
+    if (enableTrace) {
+        pn_transport_trace(engine, PN_TRACE_FRM);
+        set_tracer(engine, this);
+    }
 }
 
 ConnectionContext::~ConnectionContext()

Modified: qpid/trunk/qpid/cpp/src/qpid/messaging/amqp/ConnectionContext.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/messaging/amqp/ConnectionContext.h?rev=1548177&r1=1548176&r2=1548177&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/messaging/amqp/ConnectionContext.h (original)
+++ qpid/trunk/qpid/cpp/src/qpid/messaging/amqp/ConnectionContext.h Thu Dec  5 15:53:52 2013
@@ -114,6 +114,7 @@ class ConnectionContext : public qpid::s
     std::string getUrl() const;
     const qpid::sys::SecuritySettings* getTransportSecuritySettings();
     void initSecurityLayer(qpid::sys::SecurityLayer&);
+    void trace(const char*) const;
 
   private:
     typedef std::map<std::string, boost::shared_ptr<SessionContext> > SessionMap;



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


Mime
View raw message