1
0
mirror of https://github.com/djhackersdev/bemanitools.git synced 2025-01-19 07:17:23 +01:00

feat(util/iobuf): Improve log output

Output the full buffer and the buffer up to the
currently set position. Makes debugging a lot
easier if you know the position set is ok to
only look at the output up to there.

Otherwise, having the full view is also important
to check if data got truncated or checking for
odd looking "garbage" data.
This commit is contained in:
icex2 2023-06-11 16:48:27 +02:00 committed by icex2
parent 96d7c4ed91
commit f2628a954c

View File

@ -14,11 +14,18 @@ void iobuf_log(struct iobuf *buffer, const char *tag)
str = xmalloc(str_len);
log_misc(
"[%s] (%d %d)", tag, (uint32_t) buffer->nbytes, (uint32_t) buffer->pos);
"[%s] (nbytes %d, pos %d)",
tag,
(uint32_t) buffer->nbytes,
(uint32_t) buffer->pos);
hex_encode_uc(buffer->bytes, buffer->nbytes, str, str_len);
log_misc("[%s]: %s", tag, str);
log_misc("full [%s]: %s", tag, str);
hex_encode_uc(buffer->bytes, buffer->pos, str, str_len);
log_misc("pos [%s]: %s", tag, str);
free(str);
}
@ -32,11 +39,18 @@ void iobuf_log_const(struct const_iobuf *buffer, const char *tag)
str = xmalloc(str_len);
log_misc(
"[%s] (%d %d)", tag, (uint32_t) buffer->nbytes, (uint32_t) buffer->pos);
"[%s] (nbytes %d, pos %d)",
tag,
(uint32_t) buffer->nbytes,
(uint32_t) buffer->pos);
hex_encode_uc(buffer->bytes, buffer->nbytes, str, str_len);
log_misc("[%s]: %s", tag, str);
log_misc("full [%s]: %s", tag, str);
hex_encode_uc(buffer->bytes, buffer->pos, str, str_len);
log_misc("pos [%s]: %s", tag, str);
free(str);
}