--verbose & GS_DEBUG ignored when stderr is journald
As previously discussed on #2082 (comment 1679187) I would like to arrange for Software to always emit verbose output, so that I can more easily diagnose issues & write useful bug reports.
Typically gnome-software
's stderr is connected to the journal. This is what I want – to be able to look back at the journal when something weird has happened.
However, when gnome-software
detects that its stderr is journald, it invokes a different log writer function which forwards ERROR, CRITICAL, WARNING and INFO-grade log messages to the journal, and discards everything else. It does this regardless of whether the verbose flag has been set (whether via --verbose
or via the GS_DEBUG
environment variable).
Before 82d3664c, all messages at those 4 levels were always logged to the journal, regardless of whether stderr was or was not the journal. (Objectively weird behaviour.)
I think something more like this would be more appropriate:
diff --git a/lib/gs-debug.c b/lib/gs-debug.c
index 9d755967d..5828394f3 100644
--- a/lib/gs-debug.c
+++ b/lib/gs-debug.c
@@ -146,6 +146,8 @@ gs_log_writer_journald (GLogLevelFlags log_level,
gsize n_fields,
gpointer user_data)
{
+ GsDebug *debug = GS_DEBUG (user_data);
+
/* important enough to force to the journal */
switch (log_level) {
case G_LOG_LEVEL_ERROR:
@@ -154,6 +156,12 @@ gs_log_writer_journald (GLogLevelFlags log_level,
case G_LOG_LEVEL_INFO:
return g_log_writer_journald (log_level, fields, n_fields, user_data);
break;
+
+ case G_LOG_LEVEL_DEBUG:
+ if (g_atomic_int_get (&debug->verbose))
+ return g_log_writer_journald (log_level, fields, n_fields, user_data);
+ break;
+
default:
break;
}
(as an aside: what about G_LOG_LEVEL_MESSAGE?)