mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-19 07:00:10 -05:00
spa: add topic-based logging
Add a struct spa_log_topic that allows for logical grouping of messages. The new macros spa_log_logt() and spa_log_logtv() take a topic as argument, the topic's level acts as filter. A new macro spa_log_topic_init() initializes a topic. By default a topic inherits its logger's debug level but a logger implementation may set that topic to a specific fixed log level. The various spa_log_*() macros transparently wrap new and old implementations: - if the implementation is version 0, the new logt() calls drop the topic and get routed into the old log() calls - if the implementation is version 1, the old log() calls use a NULL topic and get routed into the new logt() calls All spa_log_* macros use the SPA_LOG_DEFAULT_TOPIC topic (NULL), it is up to the caller to redefine that. Alternatively, use spa_logt_* to pass an explicit topic. There is one crucial flaw in this implementation: log topics are initialized to their target level by the current logger. Where a topic is initialized but the logger is switched later, the topic is not automatically re-initialized. Ultimately this shouldn't matter for real-world use-cases.
This commit is contained in:
parent
26cfdc95cc
commit
0e60e9c063
4 changed files with 387 additions and 12 deletions
|
|
@ -207,6 +207,7 @@ struct spa_fraction {
|
|||
#define SPA_SENTINEL __attribute__((__sentinel__))
|
||||
#define SPA_UNUSED __attribute__ ((unused))
|
||||
#define SPA_NORETURN __attribute__ ((noreturn))
|
||||
#define SPA_WEAK __attribute__ ((weak))
|
||||
#else
|
||||
#define SPA_PRINTF_FUNC(fmt, arg1)
|
||||
#define SPA_FORMAT_ARG_FUNC(arg1)
|
||||
|
|
@ -216,6 +217,7 @@ struct spa_fraction {
|
|||
#define SPA_SENTINEL
|
||||
#define SPA_UNUSED
|
||||
#define SPA_NORETURN
|
||||
/* SPA_WEAK intentionally undef here */
|
||||
#endif
|
||||
|
||||
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue