gmessages: Treat DEBUG_INVOCATION=1 same as G_MESSAGES_DEBUG=all

systemd 257 will now set `DEBUG_INVOCATION=1` in the execution context
of services which need to be debugged — for example if they’ve failed
and been restarted (and `RestartMode=debug`).

If we handle `DEBUG_INVOCATION=1` as being equivalent to
`G_MESSAGES_DEBUG=all`, then any processes using GLib’s default log
writer function (or `g_log_writer_default_would_drop()`) automatically
gains support for this feature.

See https://mastodon.social/@pid_eins/113548825942383777

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
This commit is contained in:
Philip Withnall
2024-11-26 15:38:41 +00:00
parent dfe252429c
commit 8b29c53057
3 changed files with 40 additions and 16 deletions

View File

@@ -92,13 +92,14 @@ The default log functions (`g_log_default_handler()` for the old-style API
and `g_log_writer_default()` for the structured API) both drop debug and
informational messages by default, unless the log domains of those messages
are listed in the `G_MESSAGES_DEBUG` environment variable (or it is set to
`all`).
`all`), or `DEBUG_INVOCATION=1` is set in the environment.
It is recommended that custom log writer functions re-use the
`G_MESSAGES_DEBUG` environment variable, rather than inventing a custom one,
so that developers can re-use the same debugging techniques and tools across
projects. Since GLib 2.68, this can be implemented by dropping messages for
which `g_log_writer_default_would_drop()` returns `TRUE`.
`G_MESSAGES_DEBUG` and `DEBUG_INVOCATION` environment variables, rather than
inventing a custom one, so that developers can re-use the same debugging
techniques and tools across projects. Since GLib 2.68, this can be implemented
by dropping messages for which `g_log_writer_default_would_drop()` returns
`TRUE`.
## Testing for Messages