summaryrefslogtreecommitdiff
path: root/src/log.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/log.c')
-rw-r--r--src/log.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/log.c b/src/log.c
index 08382cd..847baf7 100644
--- a/src/log.c
+++ b/src/log.c
@@ -229,3 +229,30 @@ void log_printf(log_prio_t prio, const char* fmt, ...)
log_targets_log(&stdlog.targets_, prio, msg);
}
+
+void log_print_hex_dump(log_prio_t prio, const u_int8_t* buf, u_int32_t len)
+{
+ if(stdlog.max_prio_ < prio)
+ return;
+
+ static char msg[MSG_LENGTH_MAX];
+
+ if(!buf) {
+ snprintf(msg, MSG_LENGTH_MAX, "(NULL)");
+ }
+ else {
+ u_int32_t i;
+ int offset = snprintf(msg, MSG_LENGTH_MAX, "dump(%d): ", len);
+ if(offset < 0)
+ return;
+ u_int8_t* ptr = &msg[offset];
+
+ for(i=0; i < len; i++) {
+ if(((i+1)*3) >= (MSG_LENGTH_MAX - offset))
+ break;
+ sprintf(ptr, "%02X ", buf[i]);
+ ptr+=3;
+ }
+ }
+ log_targets_log(&stdlog.targets_, prio, msg);
+}