log: prepend topic to journald logs & add locations on debug levels
Logging messages are usually developed based on the stderr logging, which shows code location and log topics as context, and especially higher log level messages can be cryptic or useless without that context.
This context is not shown in journalctl by default, and so usually is missing from logs submitted by users. In principle it is available in journalctl but requires extra work to show it.
Fix by prepending the log topic to the messages, like Pipewire logging does. Also show code locations if log level is high enough.
log: add wp_logt_checked taking WpLogTopic, to decide on debug messages
Make decision on whether to show code location in journal messages based on whether the WpLogTopic would enable DEBUG level messages.
Add wp_logt_checked API to take WpLogTopic as input to make this possible, and deprecate wp_log_checked.
It will look like:
$ journalctl --user -u wireplumber -f
huhti 28 16:09:10 host wireplumber[606177]: s-monitors-utils: device number invalid for v4l2 device:nil
$ wpctl set-log-level 5
$ journalctl --user -u wireplumber -f
huhti 28 16:09:25 host wireplumber[606177]: T wp-object-manager [object-manager.c:669:idle_emit_objects_changed]: <WpObjectManager:0x507000032980> emit objects-changed
huhti 28 16:09:25 host wireplumber[606177]: T wp-object-manager [object-manager.c:669:idle_emit_objects_changed]: <WpObjectManager:0x50700003f560> emit objects-changed
huhti 28 16:09:25 host wireplumber[606177]: T wp-object-manager [object-manager.c:669:idle_emit_objects_changed]: <WpObjectManager:0x507000088430> emit objects-changed
The log level is also important to explicitly show at higher log levels --- both debug and trace level messages go to LOG_DEBUG priority, so they are not possible to distinguish otherwise. Moreover, it is useful to have the level for grepping etc.