This is an automated email from the ASF dual-hosted git repository.

asf-gitbox-commits pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/qpid-proton.git

commit 48209807deb6ae3a36c28915a78656cd1acdf0be
Author: Andrew Stitcher <[email protected]>
AuthorDate: Tue May 26 14:26:54 2026 -0400

    PROTON-2935: Setting default logger sink doesn't fully work
    
    If you change the default logger sink before creating a transport then
    the context that you set for the default logger would get overwritten.
---
 c/src/core/logger.c         | 6 ++++--
 c/src/core/logger_private.h | 2 +-
 c/src/core/transport.c      | 2 +-
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/c/src/core/logger.c b/c/src/core/logger.c
index 492c6c341..b9bf7cb45 100644
--- a/c/src/core/logger.c
+++ b/c/src/core/logger.c
@@ -44,10 +44,12 @@ static pn_logger_t the_default_logger = {
   .sev_mask = PN_LEVEL_CRITICAL
 };
 
-void pni_logger_init(pn_logger_t *logger)
+void pni_logger_default_init(pn_logger_t *logger)
 {
   *logger = the_default_logger;
-  logger->sink_context = (intptr_t) logger;
+  if (logger->sink == pni_default_log_sink) {
+    logger->sink_context = (intptr_t) logger;
+  }
 }
 
 void pni_logger_fini(pn_logger_t *logger)
diff --git a/c/src/core/logger_private.h b/c/src/core/logger_private.h
index d1974073e..81c3a8373 100644
--- a/c/src/core/logger_private.h
+++ b/c/src/core/logger_private.h
@@ -38,7 +38,7 @@ struct pn_logger_t {
 void pni_init_default_logger(void);
 void pni_fini_default_logger(void);
 
-void pni_logger_init(pn_logger_t*);
+void pni_logger_default_init(pn_logger_t*);
 void pni_logger_fini(pn_logger_t*);
 
 void pni_logger_log(pn_logger_t *logger, pn_log_subsystem_t subsystem, 
pn_log_level_t severity, const char *message);
diff --git a/c/src/core/transport.c b/c/src/core/transport.c
index 63f642e73..313e96ada 100644
--- a/c/src/core/transport.c
+++ b/c/src/core/transport.c
@@ -407,7 +407,7 @@ static void pn_transport_initialize(void *object)
   transport->output_size = PN_TRANSPORT_INITIAL_BUFFER_SIZE;
   transport->input_buf = NULL;
   transport->input_size =  PN_TRANSPORT_INITIAL_BUFFER_SIZE;
-  pni_logger_init(&transport->logger);
+  pni_logger_default_init(&transport->logger);
   transport->tracer = NULL;
   transport->sasl = NULL;
   transport->ssl = NULL;


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to