[gnome-software] trivial: Do not always log verbosely
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] trivial: Do not always log verbosely
- Date: Wed, 13 Apr 2016 16:35:47 +0000 (UTC)
commit f753ace487af69fa69fbc947096ccbec684765c8
Author: Richard Hughes <richard hughsie com>
Date: Wed Apr 13 15:52:45 2016 +0100
trivial: Do not always log verbosely
src/gs-application.c | 2 +-
src/gs-cmd.c | 5 +++++
src/gs-debug.c | 11 +++++++++--
3 files changed, 15 insertions(+), 3 deletions(-)
---
diff --git a/src/gs-application.c b/src/gs-application.c
index 463813c..51fe008 100644
--- a/src/gs-application.c
+++ b/src/gs-application.c
@@ -809,7 +809,7 @@ gs_application_handle_local_options (GApplication *app, GVariantDict *options)
g_autoptr(GError) error = NULL;
if (g_variant_dict_contains (options, "verbose"))
- g_setenv ("G_MESSAGES_DEBUG", "all", TRUE);
+ g_setenv ("GS_DEBUG", "1", TRUE);
/* prefer local sources */
if (g_variant_dict_contains (options, "prefer-local"))
diff --git a/src/gs-cmd.c b/src/gs-cmd.c
index d626677..e097d0f 100644
--- a/src/gs-cmd.c
+++ b/src/gs-cmd.c
@@ -200,6 +200,7 @@ main (int argc, char **argv)
gboolean prefer_local = FALSE;
gboolean ret;
gboolean show_results = FALSE;
+ gboolean verbose = FALSE;
guint64 refine_flags = GS_PLUGIN_REFINE_FLAGS_DEFAULT;
gint i;
gint cache_age = 0;
@@ -223,6 +224,8 @@ main (int argc, char **argv)
"Use this maximum cache age in seconds", NULL },
{ "prefer-local", '\0', 0, G_OPTION_ARG_NONE, &prefer_local,
"Prefer local file sources to AppStream", NULL },
+ { "verbose", '\0', 0, G_OPTION_ARG_NONE, &verbose,
+ "Show verbose debugging information", NULL },
{ NULL}
};
@@ -244,6 +247,8 @@ main (int argc, char **argv)
g_print ("Failed to parse options: %s\n", error->message);
goto out;
}
+ if (verbose)
+ g_setenv ("GS_DEBUG", "1", TRUE);
/* prefer local sources */
if (prefer_local)
diff --git a/src/gs-debug.c b/src/gs-debug.c
index abc5bec..2efe98d 100644
--- a/src/gs-debug.c
+++ b/src/gs-debug.c
@@ -36,12 +36,19 @@ gs_debug_handler_cb (const gchar *log_domain,
GsDebug *debug = (GsDebug *) user_data;
guint i;
g_autofree gchar *tmp = NULL;
- g_autoptr(GDateTime) dt = g_date_time_new_now_utc ();
g_autoptr(GString) domain = NULL;
- g_autoptr(GMutexLocker) locker = g_mutex_locker_new (&debug->mutex);
+ g_autoptr(GMutexLocker) locker = NULL;
+
+ /* enabled */
+ if (g_getenv ("GS_DEBUG") == NULL && log_level == G_LOG_LEVEL_DEBUG)
+ return;
+
+ /* make threadsafe */
+ locker = g_mutex_locker_new (&debug->mutex);
/* time header */
if (debug->use_time) {
+ g_autoptr(GDateTime) dt = g_date_time_new_now_utc ();
tmp = g_strdup_printf ("%02i:%02i:%02i:%04i",
g_date_time_get_hour (dt),
g_date_time_get_minute (dt),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]