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

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


The following commit(s) were added to refs/heads/main by this push:
     new 89082f1  PROTON-2476: Restore truncation behaviour for transfer frame 
traces
89082f1 is described below

commit 89082f1eb4c1ca16407bc0a612b3b439868a2749
Author: Andrew Stitcher <astitc...@apache.org>
AuthorDate: Tue Dec 14 15:10:16 2021 -0500

    PROTON-2476: Restore truncation behaviour for transfer frame traces
    
    The logging changes that came with PROTON-2448 had the side effect of no
    longer truncating the message payloads that came along with transfer
    frames.
    
    This meant that these trace lines could get extremely long if applications
    were sending long messages and could also take a very long time to allocate
    memory and format the string.
---
 c/src/core/logger.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/c/src/core/logger.c b/c/src/core/logger.c
index cc794fd..c222e7b 100644
--- a/c/src/core/logger.c
+++ b/c/src/core/logger.c
@@ -234,8 +234,13 @@ void pni_logger_log_msg_frame(pn_logger_t *logger, 
pn_log_subsystem_t subsystem,
   size_t psize = pn_value_dump(frame, logger->scratch);
   pn_bytes_t payload = {.size=frame.size-psize, .start=frame.start+psize};
   if (payload.size>0) {
-    pn_string_addf(logger->scratch, " (%zu) ", payload.size);
-    pn_quote(logger->scratch, payload.start, payload.size);
+    char buf[512];
+    ssize_t n = pn_quote_data(buf, sizeof(buf), payload.start, payload.size);
+    if (n >= 0) {
+      pn_string_addf(logger->scratch, " (%zu) %s", payload.size, buf);
+    } else if (n == PN_OVERFLOW) {
+      pn_string_addf(logger->scratch, " (%zu) %s ... (truncated)", 
payload.size, buf);
+    }
   }
   pni_logger_log(logger, subsystem, severity, pn_string_get(logger->scratch));
 }

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

Reply via email to