spa: add debug log context

Make a real debug context with a log function and move it to a new file.
This way we don't need to redefine a macro.
Make a new context for debugging to a log file. Make new functions to
debug to a log file.
Move the stringbuffer to string utils.
Integrate file/line/func and topics into the debug log.
We can remove some more things from the pipewire log_object function and
also add support for topics.
This commit is contained in:
Wim Taymans 2023-01-18 17:41:16 +01:00
parent 3c67821c4a
commit 6207d98ff1
21 changed files with 231 additions and 164 deletions

View file

@ -40,16 +40,14 @@
#include <spa/param/param.h>
#include <spa/param/video/format-utils.h>
#include <spa/param/latency-utils.h>
#include <spa/debug/format.h>
#include <spa/debug/pod.h>
#include <spa/debug/log.h>
#undef SPA_LOG_TOPIC_DEFAULT
#define SPA_LOG_TOPIC_DEFAULT log_topic
static struct spa_log_topic *log_topic = &SPA_LOG_TOPIC(0, "spa.videoadapter");
#undef spa_debugc
#define spa_debugc(l,...) spa_log_debug(l, __VA_ARGS__)
#include <spa/debug/format.h>
#include <spa/debug/pod.h>
#define DEFAULT_ALIGN 16
#define MAX_PORTS 1
@ -302,7 +300,7 @@ static int debug_params(struct impl *this, struct spa_node *node,
if (filter) {
spa_log_error(this->log, "with this filter:");
spa_debugc_pod(this->log, 2, NULL, filter);
spa_debug_log_pod(this->log, SPA_LOG_LEVEL_DEBUG, 2, NULL, filter);
} else {
spa_log_error(this->log, "there was no filter");
}
@ -320,7 +318,7 @@ static int debug_params(struct impl *this, struct spa_node *node,
break;
}
spa_log_error(this->log, "unmatched %s %d:", debug, count);
spa_debugc_pod(this->log, 2, NULL, param);
spa_debug_log_pod(this->log, SPA_LOG_LEVEL_DEBUG, 2, NULL, param);
count++;
}
if (count == 0)
@ -445,8 +443,8 @@ static int configure_format(struct impl *this, uint32_t flags, const struct spa_
int res;
spa_log_debug(this->log, "%p: configure format:", this);
if (format && spa_log_level_enabled(this->log, SPA_LOG_LEVEL_DEBUG))
spa_debugc_format(this->log, 0, NULL, format);
if (format)
spa_debug_log_format(this->log, SPA_LOG_LEVEL_DEBUG, 0, NULL, format);
if ((res = spa_node_port_set_param(this->follower,
this->direction, 0,