[gnome-software/mwleeds/honor-g-messages-debug] Honor G_MESSAGES_DEBUG env var
- From: Phaedrus Leeds <mwleeds src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/mwleeds/honor-g-messages-debug] Honor G_MESSAGES_DEBUG env var
- Date: Wed, 17 Feb 2021 19:48:51 +0000 (UTC)
commit 0e752fd9c781b2129aaeec5d1fef4ec6bdfd8f21
Author: Phaedrus Leeds <mwleeds endlessos org>
Date: Wed Feb 17 11:46:48 2021 -0800
Honor G_MESSAGES_DEBUG env var
Instead of requiring the --verbose command line argument, also respect
the G_MESSAGES_DEBUG environment variable, as is standard for GLib-based
applications.
lib/gs-debug.c | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
---
diff --git a/lib/gs-debug.c b/lib/gs-debug.c
index af278495b..a9ce19865 100644
--- a/lib/gs-debug.c
+++ b/lib/gs-debug.c
@@ -30,17 +30,14 @@ gs_log_writer_console (GLogLevelFlags log_level,
gpointer user_data)
{
GsDebug *debug = GS_DEBUG (user_data);
+ const gchar *domains = NULL;
+ const gchar *gs_debug = NULL;
const gchar *log_domain = NULL;
const gchar *log_message = NULL;
g_autofree gchar *tmp = NULL;
g_autoptr(GMutexLocker) locker = NULL;
g_autoptr(GString) domain = NULL;
- /* enabled */
- if (g_getenv ("GS_DEBUG") == NULL &&
- log_level == G_LOG_LEVEL_DEBUG)
- return G_LOG_WRITER_HANDLED;
-
/* get data from arguments */
for (gsize i = 0; i < n_fields; i++) {
if (g_strcmp0 (fields[i].key, "MESSAGE") == 0) {
@@ -53,6 +50,21 @@ gs_log_writer_console (GLogLevelFlags log_level,
}
}
+ domains = g_getenv ("G_MESSAGES_DEBUG");
+ gs_debug = g_getenv ("GS_DEBUG");
+
+ /* enabled */
+ if ((log_level == G_LOG_LEVEL_DEBUG ||
+ log_level == G_LOG_LEVEL_INFO) &&
+ gs_debug == NULL) {
+ if (domains == NULL || *domains == '\0')
+ return G_LOG_WRITER_HANDLED;
+
+ if (g_strcmp0 (domains, "all") != 0 &&
+ (log_domain == NULL || !strstr (domains, log_domain)))
+ return G_LOG_WRITER_HANDLED;
+ }
+
/* this is really verbose */
if ((g_strcmp0 (log_domain, "dconf") == 0 ||
g_strcmp0 (log_domain, "GLib-GIO") == 0 ||
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]