qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From astitc...@apache.org
Subject qpid-proton git commit: PROTON-1237: Improve connection_engine event logging
Date Tue, 26 Jul 2016 19:52:36 GMT
Repository: qpid-proton
Updated Branches:
  refs/heads/master d324e5cd9 -> fd550fe0a


PROTON-1237: Improve connection_engine event logging


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/fd550fe0
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/fd550fe0
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/fd550fe0

Branch: refs/heads/master
Commit: fd550fe0ac63cd134e68eccd60c232de1bc7d6c2
Parents: d324e5c
Author: Andrew Stitcher <astitcher@apache.org>
Authored: Tue Jul 26 15:42:45 2016 -0400
Committer: Andrew Stitcher <astitcher@apache.org>
Committed: Tue Jul 26 15:44:13 2016 -0400

----------------------------------------------------------------------
 proton-c/include/proton/transport.h     |  6 ++++++
 proton-c/src/engine/connection_engine.c | 26 ++++++--------------------
 proton-c/src/transport/transport.c      |  6 ++++--
 3 files changed, 16 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/fd550fe0/proton-c/include/proton/transport.h
----------------------------------------------------------------------
diff --git a/proton-c/include/proton/transport.h b/proton-c/include/proton/transport.h
index cfa6d71..5c8494c 100644
--- a/proton-c/include/proton/transport.h
+++ b/proton-c/include/proton/transport.h
@@ -52,6 +52,7 @@ extern "C" {
  * - ::PN_TRACE_RAW
  * - ::PN_TRACE_FRM
  * - ::PN_TRACE_DRV
+ * - ::PN_TRACE_EVT
  *
  */
 typedef int pn_trace_t;
@@ -82,6 +83,11 @@ typedef void (*pn_tracer_t)(pn_transport_t *transport, const char *message);
 #define PN_TRACE_DRV (4)
 
 /**
+ * Log events
+ */
+#define PN_TRACE_EVT (8)
+
+/**
  * Factory for creating a transport.
  * A transport is used by a connection to interface with the network.
  * There can only be one connection associated with a transport. See

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/fd550fe0/proton-c/src/engine/connection_engine.c
----------------------------------------------------------------------
diff --git a/proton-c/src/engine/connection_engine.c b/proton-c/src/engine/connection_engine.c
index ab4f927..75a16ae 100644
--- a/proton-c/src/engine/connection_engine.c
+++ b/proton-c/src/engine/connection_engine.c
@@ -16,8 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-
-#include "util.h"
+#include "engine-internal.h"
 
 #include <proton/connection.h>
 #include <proton/connection_engine.h>
@@ -105,25 +104,12 @@ void pn_connection_engine_disconnected(pn_connection_engine_t* e) {
     pn_connection_engine_write_close(e);
 }
 
-enum { LOG_DISABLED, LOG_ENABLED, LOG_UNKNOWN };
-
 static void log_event(pn_connection_engine_t *engine, pn_event_t* event) {
-    if (!event)
-        return;
-    static int enabled = LOG_UNKNOWN;
-    // Switch so this can be evaluated as a single branch.
-    switch (enabled) {
-      case LOG_DISABLED:
-        return;
-      case LOG_ENABLED:
-        pn_transport_log(engine->transport, pn_event_type_name(pn_event_type(event)));
-        return;
-      case LOG_UNKNOWN:
-        enabled = pn_env_bool("PN_TRACE_EVENT") ? LOG_ENABLED : LOG_DISABLED;
-        if (enabled == LOG_ENABLED) {
-            pn_transport_log(engine->transport, pn_event_type_name(pn_event_type(event)));
-        }
-        return;
+    if (event && engine->transport->trace & PN_TRACE_EVT) {
+        pn_string_t *str = pn_string(NULL);
+        pn_inspect(event, str);
+        pn_transport_log(engine->transport, pn_string_get(str));
+        pn_free(str);
     }
 }
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/fd550fe0/proton-c/src/transport/transport.c
----------------------------------------------------------------------
diff --git a/proton-c/src/transport/transport.c b/proton-c/src/transport/transport.c
index 07ee1f6..1d7cc87 100644
--- a/proton-c/src/transport/transport.c
+++ b/proton-c/src/transport/transport.c
@@ -486,9 +486,11 @@ static void pn_transport_initialize(void *object)
 
   transport->referenced = true;
 
-  transport->trace = (pn_env_bool("PN_TRACE_RAW") ? PN_TRACE_RAW : PN_TRACE_OFF) |
+  transport->trace =
+    (pn_env_bool("PN_TRACE_RAW") ? PN_TRACE_RAW : PN_TRACE_OFF) |
     (pn_env_bool("PN_TRACE_FRM") ? PN_TRACE_FRM : PN_TRACE_OFF) |
-    (pn_env_bool("PN_TRACE_DRV") ? PN_TRACE_DRV : PN_TRACE_OFF);
+    (pn_env_bool("PN_TRACE_DRV") ? PN_TRACE_DRV : PN_TRACE_OFF) |
+    (pn_env_bool("PN_TRACE_EVT") ? PN_TRACE_EVT : PN_TRACE_OFF) ;
 }
 
 


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


Mime
View raw message