From 1d39ea004edfb395ee21d152dcb4f157bb7ed5d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Danis?= Date: Wed, 13 Jul 2022 10:12:27 +0200 Subject: [PATCH] log: Add spa_log_hexdump --- spa/include/spa/support/log.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/spa/include/spa/support/log.h b/spa/include/spa/support/log.h index e4990d1bb..07f390585 100644 --- a/spa/include/spa/support/log.h +++ b/spa/include/spa/support/log.h @@ -293,6 +293,24 @@ do { \ #define spa_log_trace_fp(l,...) #endif +#define spa_log_hexdump(l,lev,indent,data,len) \ +({ \ + char str[512]; \ + uint8_t *buf = (uint8_t *)data; \ + size_t i; \ + int pos; \ + \ + for (i = 0; i < len; i++) { \ + if (i % 16 == 0) \ + pos = 0; \ + pos += sprintf(str + pos, "%02x ", buf[i]); \ + if (i % 16 == 15 || i == len - 1) { \ + spa_log_log(l,lev,__FILE__,__LINE__,__func__, \ + "%*s" "%s",indent,"", str); \ + } \ + } \ +}) + /** \fn spa_log_error */ /** keys can be given when initializing the logger handle */