[gnome-color-manager] trivial: update the egg debug scripts as there's a nice ENV fix there
- From: Richard Hughes <rhughes src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-color-manager] trivial: update the egg debug scripts as there's a nice ENV fix there
- Date: Wed, 2 Dec 2009 12:38:07 +0000 (UTC)
commit d256a583834084c34883fb832b6cf035217635ee
Author: Richard Hughes <richard hughsie com>
Date: Wed Dec 2 12:37:22 2009 +0000
trivial: update the egg debug scripts as there's a nice ENV fix there
src/egg-debug.c | 63 +++++++++++++++++++++++++++++++++++-------------------
1 files changed, 41 insertions(+), 22 deletions(-)
---
diff --git a/src/egg-debug.c b/src/egg-debug.c
index 77bfa20..f734ee2 100644
--- a/src/egg-debug.c
+++ b/src/egg-debug.c
@@ -122,6 +122,24 @@ egg_debug_filter_function (const gchar *function)
}
/**
+ * egg_debug_is_console:
+ *
+ * Returns: TRUE if we are on a console
+ **/
+static gboolean
+egg_debug_is_console (void)
+{
+ /* local first */
+ if (_console)
+ return TRUE;
+
+ /* fall back to env variable */
+ if (g_getenv ("CONSOLE") != NULL)
+ return TRUE;
+ return FALSE;
+}
+
+/**
* egg_debug_set_console_mode:
**/
static void
@@ -130,7 +148,7 @@ egg_debug_set_console_mode (guint console_code)
gchar command[13];
/* don't put extra commands into logs */
- if (!_console)
+ if (!egg_debug_is_console ())
return;
/* Command is the control command to the terminal */
@@ -232,6 +250,24 @@ egg_debug_print_line (const gchar *func, const gchar *file, const int line, cons
}
/**
+ * egg_debug_is_verbose:
+ *
+ * Returns: TRUE if we have debugging enabled
+ **/
+gboolean
+egg_debug_is_verbose (void)
+{
+ /* local first */
+ if (_verbose)
+ return TRUE;
+
+ /* fall back to env variable */
+ if (g_getenv ("VERBOSE") != NULL)
+ return TRUE;
+ return FALSE;
+}
+
+/**
* egg_debug_real:
**/
void
@@ -240,7 +276,7 @@ egg_debug_real (const gchar *func, const gchar *file, const int line, const gcha
va_list args;
gchar *buffer = NULL;
- if (!_verbose && !egg_debug_filter_module (file) && !egg_debug_filter_function (func))
+ if (!egg_debug_is_verbose () && !egg_debug_filter_module (file) && !egg_debug_filter_function (func))
return;
va_start (args, format);
@@ -261,7 +297,7 @@ egg_warning_real (const gchar *func, const gchar *file, const int line, const gc
va_list args;
gchar *buffer = NULL;
- if (!_verbose && !egg_debug_filter_module (file) && !egg_debug_filter_function (func))
+ if (!egg_debug_is_verbose () && !egg_debug_filter_module (file) && !egg_debug_filter_function (func))
return;
va_start (args, format);
@@ -269,7 +305,7 @@ egg_warning_real (const gchar *func, const gchar *file, const int line, const gc
va_end (args);
/* do extra stuff for a warning */
- if (!_console)
+ if (!egg_debug_is_console ())
printf ("*** WARNING ***\n");
egg_debug_print_line (func, file, line, buffer, CONSOLE_RED);
@@ -290,7 +326,7 @@ egg_error_real (const gchar *func, const gchar *file, const int line, const gcha
va_end (args);
/* do extra stuff for a warning */
- if (!_console)
+ if (!egg_debug_is_console ())
printf ("*** ERROR ***\n");
egg_debug_print_line (func, file, line, buffer, CONSOLE_RED);
g_free (buffer);
@@ -302,17 +338,6 @@ egg_error_real (const gchar *func, const gchar *file, const int line, const gcha
}
/**
- * egg_debug_is_verbose:
- *
- * Returns: TRUE if we have debugging enabled
- **/
-gboolean
-egg_debug_is_verbose (void)
-{
- return _verbose;
-}
-
-/**
* egg_debug_set_log_filename:
**/
void
@@ -357,7 +382,6 @@ out:
static gboolean
egg_debug_pre_parse_hook (GOptionContext *context, GOptionGroup *group, gpointer data, GError **error)
{
- const gchar *env_string;
const GOptionEntry main_entries[] = {
{ "verbose", 'v', 0, G_OPTION_ARG_NONE, &_verbose,
/* TRANSLATORS: turn on all debugging */
@@ -365,11 +389,6 @@ egg_debug_pre_parse_hook (GOptionContext *context, GOptionGroup *group, gpointer
{ NULL}
};
- /* global variable */
- env_string = g_getenv ("VERBOSE");
- if (env_string != NULL)
- _verbose = TRUE;
-
/* add main entry */
g_option_context_add_main_entries (context, main_entries, NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]