From 5c1d6fb5ad1420adf0654c20ddd2bb79552866a8 Mon Sep 17 00:00:00 2001 From: Pauli Virtanen Date: Sun, 9 Mar 2025 16:14:56 +0200 Subject: [PATCH] spa: acp: make spa-acp-tool debug output easier to read Include log level, file/line numbers, and indent messages for debug levels. --- spa/plugins/alsa/acp-tool.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/spa/plugins/alsa/acp-tool.c b/spa/plugins/alsa/acp-tool.c index cff9edb80..c12401100 100644 --- a/spa/plugins/alsa/acp-tool.c +++ b/spa/plugins/alsa/acp-tool.c @@ -132,6 +132,18 @@ static ACP_PRINTF_FUNC(6,0) void log_func(void *data, int level, const char *file, int line, const char *func, const char *fmt, va_list arg) { + static const char * const levels[] = { "E", "W", "N", "I", "D", "T" }; + const char *level_str = levels[SPA_CLAMP(level, 0, (int)SPA_N_ELEMENTS(levels) - 1)]; + + if (file) { + const char *p = strrchr(file, '/'); + if (p) + file = p + 1; + } + + fprintf(stderr, "%s %16s:%-5d ", level_str, file ? file : "", line); + while (level-- > 1) + fprintf(stderr, " "); vfprintf(stderr, fmt, arg); fprintf(stderr, "\n"); }