log: add topic loggers and a default topic

pw_log_log/logv now go through the topic-based logger using the
"default" topic. Log topics themselves can be allocated by the call
sites. The simplest way to use a topic from e.g. a module:

    PW_LOG_TOPIC_STATIC(mod_topic, "mod.foo");
    #define PW_LOG_TOPIC_DEFAULT mod_topic
    ...
    void pipewire__module_init() {
  	  PW_LOG_TOPIC_INIT(mod_topic);
  	  ...
    }

With the #define all pw_log_foo() are now routed through the custom
topic. For the cases where the log topic must be specified, a
pw_logt_foo() set of macros is available.

Log topics are enabled through the PIPEWIRE_DEBUG environment variable
which now supports globs, e.g. PIPEWIRE_DEBUG="*:I;mod.access:D"
to enable global INFO but DEBUG for the access module.

Namespaces documented are "pw", "mod" and "conn", for pipewire-internal
stuff, modules and connection dumping. The latter is special-cased to
avoid spamming the log files, it requires an expcit "conn.<glob>"
pattern to enable.

The "default" topic always exists and is the fallback for any
pw_log_foo() invocation that does not use a topic.
This commit is contained in:
Peter Hutterer 2021-09-16 13:43:48 +10:00 committed by Wim Taymans
parent b58282353b
commit 52bd80aaa4
6 changed files with 308 additions and 50 deletions

View file

@ -1257,6 +1257,9 @@ void pw_log_log_object(enum spa_log_level level, const char *file, int line,
bool pw_log_is_default(void);
void pw_log_init(void);
void pw_log_deinit(void);
int pw_settings_init(struct pw_context *context);
void pw_settings_clean(struct pw_context *context);