summaryrefslogtreecommitdiff
path: root/tumbler
diff options
context:
space:
mode:
authorGaël Bonithon <gael@xfce.org>2021-12-24 23:40:38 +0100
committerGaël Bonithon <gael@xfce.org>2021-12-26 18:30:01 +0100
commit8f439a5ae5c46ce5e3868078735253ca9d03aca7 (patch)
tree1e8705bb677837f8e43bfb211306dfe2c3399e23 /tumbler
parentb014aabd2d78472a18a9b863e51dd6f1631d78cb (diff)
downloadtumbler-8f439a5ae5c46ce5e3868078735253ca9d03aca7.tar.gz
Debug: Prefer runtime to compile-time check for logging
This is more convenient for both the developer and the user, especially when it comes to providing logs in a bug report. As for the loss in terms of performance, it is minimal, and this is normally not an issue where these functions are used.
Diffstat (limited to 'tumbler')
-rw-r--r--tumbler/tumbler-util.c20
-rw-r--r--tumbler/tumbler-util.h2
2 files changed, 22 insertions, 0 deletions
diff --git a/tumbler/tumbler-util.c b/tumbler/tumbler-util.c
index 9d6fad0..c7be630 100644
--- a/tumbler/tumbler-util.c
+++ b/tumbler/tumbler-util.c
@@ -39,6 +39,26 @@
#define TUMBLER_STAT_BLKSIZE 512.
+
+/* that's what `! g_log_writer_default_would_drop (G_LOG_LEVEL_DEBUG, log_domain)` leads to:
+ * it is defined only from GLib 2.68, and it might be better to keep this anyway */
+gboolean
+tumbler_util_is_debug_logging_enabled (const gchar *log_domain)
+{
+ const gchar *domains;
+
+ domains = g_getenv ("G_MESSAGES_DEBUG");
+ if (domains == NULL)
+ return FALSE;
+
+ if (strcmp (domains, "all") == 0 || (log_domain != NULL && strstr (domains, log_domain)))
+ return TRUE;
+
+ return FALSE;
+}
+
+
+
gchar **
tumbler_util_get_supported_uri_schemes (void)
{
diff --git a/tumbler/tumbler-util.h b/tumbler/tumbler-util.h
index be030cc..037bcf3 100644
--- a/tumbler/tumbler-util.h
+++ b/tumbler/tumbler-util.h
@@ -28,6 +28,8 @@
G_BEGIN_DECLS
+gboolean tumbler_util_is_debug_logging_enabled (const gchar *log_domain);
+
gchar **tumbler_util_get_supported_uri_schemes (void) G_GNUC_MALLOC;
GKeyFile *tumbler_util_get_settings (void) G_GNUC_MALLOC;