log: improve format debug log

Use the format debug log instead of generic pod log
This commit is contained in:
Wim Taymans 2023-02-13 16:56:54 +01:00
parent b93c3fb0c5
commit 68f6d4d6de
2 changed files with 9 additions and 6 deletions

View file

@ -29,6 +29,7 @@
#include <spa/pod/pod.h>
#include <spa/debug/types.h>
#include <spa/debug/format.h>
#include <spa/pod/iter.h>
#include <spa/utils/list.h>
@ -241,13 +242,14 @@ void pw_log_log_object(enum spa_log_level level,
{
struct spa_debug_log_ctx ctx = SPA_LOGF_DEBUG_INIT(global_log, level,
topic, file, line, func );
if (flags & PW_LOG_OBJECT_POD) {
const struct spa_pod *pod = object;
if (pod == NULL) {
if (object == NULL) {
pw_log_logt(level, topic, file, line, func, "NULL");
} else {
const struct spa_pod *pod = object;
if (flags & PW_LOG_OBJECT_POD)
spa_debugc_pod(&ctx.ctx, 0, SPA_TYPE_ROOT, pod);
}
else if (flags & PW_LOG_OBJECT_FORMAT)
spa_debugc_format(&ctx.ctx, 0, NULL, pod);
}
}

View file

@ -1276,6 +1276,7 @@ void pw_control_destroy(struct pw_control *control);
void pw_impl_client_unref(struct pw_impl_client *client);
#define PW_LOG_OBJECT_POD (1<<0)
#define PW_LOG_OBJECT_FORMAT (1<<1)
void pw_log_log_object(enum spa_log_level level, const struct spa_log_topic *topic,
const char *file, int line, const char *func, uint32_t flags,
const void *object);
@ -1288,7 +1289,7 @@ void pw_log_log_object(enum spa_log_level level, const struct spa_log_topic *top
})
#define pw_log_pod(lev,pod) pw_log_object(lev,PW_LOG_TOPIC_DEFAULT,PW_LOG_OBJECT_POD,pod)
#define pw_log_format(lev,pod) pw_log_object(lev,PW_LOG_TOPIC_DEFAULT,PW_LOG_OBJECT_POD,pod)
#define pw_log_format(lev,pod) pw_log_object(lev,PW_LOG_TOPIC_DEFAULT,PW_LOG_OBJECT_FORMAT,pod)
bool pw_log_is_default(void);