[gnome-builder] log: handle G_MESSAGES_DEBUG
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] log: handle G_MESSAGES_DEBUG
- Date: Tue, 7 Aug 2018 18:25:24 +0000 (UTC)
commit 8430010d469c58d7c269a1ddd613766faa8b8835
Author: Sebastien Lafargue <slafargue gnome org>
Date: Fri May 4 14:36:11 2018 +0200
log: handle G_MESSAGES_DEBUG
Because of the way we handle the print of debug messages,
by using -vvv for debug and -vvvv for debug and traces
(both when previously activated at build time), the policy
sightly differ from GLib:
- G_MESSAGES_DEBUG is thus only used when using -vvv or -vvvv
- if G_MESSAGES_DEBUG is not defined or defined to 'all', those
messages are printed.
- if the message log domain is not in the G_MESSAGES_DEBUG
space-separated list, it will not be printed.
src/libide/logging/ide-log.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
---
diff --git a/src/libide/logging/ide-log.c b/src/libide/logging/ide-log.c
index d814058f4..d0ce99901 100644
--- a/src/libide/logging/ide-log.c
+++ b/src/libide/logging/ide-log.c
@@ -34,6 +34,8 @@
#include <time.h>
#include <unistd.h>
+#include <dazzle.h>
+
#include "ide-debug.h"
#include "logging/ide-log.h"
@@ -90,6 +92,8 @@ static GPtrArray *channels;
static GLogFunc last_handler;
static int log_verbosity;
static IdeLogLevelStrFunc log_level_str_func;
+static gchar *domains;
+static gboolean has_domains;
G_LOCK_DEFINE (channels_lock);
@@ -193,9 +197,16 @@ ide_log_handler (const gchar *log_domain,
const gchar *level;
gchar ftime[32];
gchar *buffer;
+ gboolean is_debug_level;
if (G_LIKELY (channels->len))
{
+ is_debug_level = (log_level == G_LOG_LEVEL_DEBUG || log_level == IDE_LOG_LEVEL_TRACE);
+ if (is_debug_level &&
+ has_domains &&
+ (log_domain == NULL || strstr (domains, log_domain) == NULL))
+ return;
+
switch ((int)log_level)
{
case G_LOG_LEVEL_MESSAGE:
@@ -276,6 +287,10 @@ ide_log_init (gboolean stdout_,
log_level_str_func = ide_log_level_str_with_color;
}
+ domains = g_strdup (g_getenv ("G_MESSAGES_DEBUG"));
+ if (!dzl_str_empty0 (domains) && strcmp (domains, "all") != 0)
+ has_domains = TRUE;
+
g_log_set_default_handler (ide_log_handler, NULL);
g_once_init_leave (&initialized, TRUE);
}
@@ -297,6 +312,8 @@ ide_log_shutdown (void)
g_log_set_default_handler (last_handler, NULL);
last_handler = NULL;
}
+
+ g_clear_pointer (&domains, g_free);
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]