Author: rhs
Date: Tue Oct 2 18:22:49 2012
New Revision: 1393082
URL: http://svn.apache.org/viewvc?rev=1393082&view=rev
Log:
added truncate for logging of large data
Modified:
qpid/proton/trunk/proton-c/src/dispatcher/dispatcher.c
qpid/proton/trunk/proton-c/src/util.c
Modified: qpid/proton/trunk/proton-c/src/dispatcher/dispatcher.c
URL:
http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/dispatcher/dispatcher.c?rev=1393082&r1=1393081&r2=1393082&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/src/dispatcher/dispatcher.c (original)
+++ qpid/proton/trunk/proton-c/src/dispatcher/dispatcher.c Tue Oct 2 18:22:49
2012
@@ -87,10 +87,10 @@ static void pn_do_trace(pn_dispatcher_t
pn_dispatcher_trace(disp, ch, "%s %s %s", dir == OUT ? "->" : "<-",
disp->names[code], disp->scratch);
if (size) {
- size_t capacity = 4*size + 1;
- char buf[capacity];
- pn_quote_data(buf, capacity, payload, size);
- fprintf(stderr, " (%zu) \"%s\"\n", size, buf);
+ char buf[1024];
+ int e = pn_quote_data(buf, 1024, payload, size);
+ fprintf(stderr, " (%zu) \"%s\"%s\n", size, buf,
+ e == PN_OVERFLOW ? "... (truncated)" : "");
} else {
fprintf(stderr, "\n");
}
Modified: qpid/proton/trunk/proton-c/src/util.c
URL:
http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/util.c?rev=1393082&r1=1393081&r2=1393082&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/src/util.c (original)
+++ qpid/proton/trunk/proton-c/src/util.c Tue Oct 2 18:22:49 2012
@@ -41,12 +41,14 @@ ssize_t pn_quote_data(char *dst, size_t
if (idx < (int) (capacity - 1)) {
dst[idx++] = c;
} else {
+ dst[idx - 1] = '\0';
return PN_OVERFLOW;
}
} else {
if (idx < (int) (capacity - 4)) {
idx += sprintf(dst + idx, "\\x%.2x", c);
} else {
+ dst[idx - 1] = '\0';
return PN_OVERFLOW;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]