qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acon...@apache.org
Subject [2/6] qpid-proton git commit: PROTON-1419: c libuv proactor log all events
Date Mon, 27 Feb 2017 18:04:50 GMT
PROTON-1419: c libuv proactor log all events

Use the pn_log() function to log listener and proactor events when PN_TRACE_LOG is set.

The current logging features are not ideal but this fix is consistent with the
status quo so if/when we upgrade the logging framework this will be included.

Add missing function definition for  pn_connection_driver_logf


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

Branch: refs/heads/master
Commit: 54e8099e274938db1a3d458eff18c374af149945
Parents: 57e6aba
Author: Alan Conway <aconway@redhat.com>
Authored: Mon Feb 27 11:30:37 2017 -0500
Committer: Alan Conway <aconway@redhat.com>
Committed: Mon Feb 27 11:30:37 2017 -0500

----------------------------------------------------------------------
 proton-c/include/proton/connection_driver.h |  2 +-
 proton-c/src/core/connection_driver.c       |  9 ++++++---
 proton-c/src/core/log_private.h             |  6 +++---
 proton-c/src/proactor/libuv.c               | 13 +++++++++++--
 4 files changed, 21 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/54e8099e/proton-c/include/proton/connection_driver.h
----------------------------------------------------------------------
diff --git a/proton-c/include/proton/connection_driver.h b/proton-c/include/proton/connection_driver.h
index 53a9c56..5632050 100644
--- a/proton-c/include/proton/connection_driver.h
+++ b/proton-c/include/proton/connection_driver.h
@@ -227,7 +227,7 @@ PN_EXTERN void pn_connection_driver_log(pn_connection_driver_t *d, const
char *m
 /**
  * Log a printf formatted message using the connection's transport log.
  */
-PN_EXTERN void pn_connection_driver_logf(pn_connection_driver_t *d, char *fmt, ...);
+PN_EXTERN void pn_connection_driver_logf(pn_connection_driver_t *d, const char *fmt, ...);
 
 /**
  * Log a printf formatted message using the connection's transport log.

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/54e8099e/proton-c/src/core/connection_driver.c
----------------------------------------------------------------------
diff --git a/proton-c/src/core/connection_driver.c b/proton-c/src/core/connection_driver.c
index 3393e64..b4d8178 100644
--- a/proton-c/src/core/connection_driver.c
+++ b/proton-c/src/core/connection_driver.c
@@ -153,12 +153,15 @@ void pn_connection_driver_log(pn_connection_driver_t *d, const char
*msg) {
   pn_transport_log(d->transport, msg);
 }
 
-void pn_connection_driver_vlogf(pn_connection_driver_t *d, const char *fmt, va_list ap) {
+void pn_connection_driver_logf(pn_connection_driver_t *d, const char *fmt, ...) {
+  va_list ap;
+  va_start(ap, fmt);
   pn_transport_vlogf(d->transport, fmt, ap);
+  va_end(ap);
 }
 
-void pn_connection_driver_vlog(pn_connection_driver_t *d, const char *msg) {
-  pn_transport_log(d->transport, msg);
+void pn_connection_driver_vlogf(pn_connection_driver_t *d, const char *fmt, va_list ap) {
+  pn_transport_vlogf(d->transport, fmt, ap);
 }
 
 pn_connection_driver_t* pn_event_batch_connection_driver(pn_event_batch_t *batch) {

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/54e8099e/proton-c/src/core/log_private.h
----------------------------------------------------------------------
diff --git a/proton-c/src/core/log_private.h b/proton-c/src/core/log_private.h
index 4725045..828e189 100644
--- a/proton-c/src/core/log_private.h
+++ b/proton-c/src/core/log_private.h
@@ -42,12 +42,12 @@
     } while(0)
 
 /** Return true if logging is enabled. */
-bool pn_log_enabled(void);
+PN_EXTERN bool pn_log_enabled(void);
 
 /**@internal*/
-void pn_logf_impl(const char* fmt, ...);
+PN_EXTERN void pn_logf_impl(const char* fmt, ...);
 /**@internal*/
-void pn_vlogf_impl(const char *fmt, va_list ap);
+PN_EXTERN void pn_vlogf_impl(const char *fmt, va_list ap);
 
 
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/54e8099e/proton-c/src/proactor/libuv.c
----------------------------------------------------------------------
diff --git a/proton-c/src/proactor/libuv.c b/proton-c/src/proactor/libuv.c
index 61239ac..8e2ff05 100644
--- a/proton-c/src/proactor/libuv.c
+++ b/proton-c/src/proactor/libuv.c
@@ -19,6 +19,8 @@
  *
  */
 
+#include "../core/log_private.h"
+
 #include <proton/condition.h>
 #include <proton/connection_driver.h>
 #include <proton/engine.h>
@@ -883,6 +885,13 @@ void pn_proactor_free(pn_proactor_t *p) {
   free(p);
 }
 
+static pn_event_t *log_event(void* p, pn_event_t *e) {
+  if (e) {
+    pn_logf("[%p]:(%s)", (void*)p, pn_event_type_name(pn_event_type(e)));
+  }
+  return e;
+}
+
 static pn_event_t *listener_batch_next(pn_event_batch_t *batch) {
   pn_listener_t *l = batch_listener(batch);
   assert(l->psocket.state == ON_WORKER);
@@ -890,13 +899,13 @@ static pn_event_t *listener_batch_next(pn_event_batch_t *batch) {
   if (prev && pn_event_type(prev) == PN_LISTENER_CLOSE) {
     l->err = UV_EOF;
   }
-  return pn_collector_next(l->collector);
+  return log_event(l, pn_collector_next(l->collector));
 }
 
 static pn_event_t *proactor_batch_next(pn_event_batch_t *batch) {
   pn_proactor_t *p = batch_proactor(batch);
   assert(p->batch_working);
-  return pn_collector_next(p->collector);
+  return log_event(p, pn_collector_next(p->collector));
 }
 
 static void pn_listener_free(pn_listener_t *l) {


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


Mime
View raw message