summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoriain <iain@linux.intel.com>2011-08-25 15:59:45 +0100
committeriain <iain@linux.intel.com>2011-08-25 15:59:45 +0100
commit8524a09288e670a62ed4158bb13faad155fb5d81 (patch)
tree905902241b762d09ceef48f0f9dfb4bc97ffab31
parent513672a0b880e666e4317e4db997175f9a7bde01 (diff)
Initialise the Gypsy debugging system
-rw-r--r--src/main.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c
index 6cc0e26..838b176 100644
--- a/src/main.c
+++ b/src/main.c
@@ -39,6 +39,7 @@
#include <dbus/dbus-glib.h>
#include <dbus/dbus-glib-bindings.h>
+#include "gypsy-debug.h"
#include "gypsy-server.h"
#define GYPSY_NAME "org.freedesktop.Gypsy"
@@ -48,6 +49,11 @@ static GMainLoop *mainloop;
/* This is a bit ugly, but it works */
char* nmea_log = NULL;
+guint gypsy_debug_flags = 0; /* global gypsy debug flag */
+static const GDebugKey gypsy_debug_keys[] = {
+ { "nmea", GYPSY_DEBUG_NMEA },
+};
+
static void
gypsy_terminate (GObject *object,
gpointer userdata)
@@ -85,6 +91,26 @@ name_owner_changed (DBusGProxy *proxy,
}
}
+static gboolean
+gypsy_arg_debug_cb (const char *key,
+ const char *value,
+ gpointer userdata)
+{
+ gypsy_debug_flags |= g_parse_debug_string
+ (value, gypsy_debug_keys, G_N_ELEMENTS (gypsy_debug_keys));
+ return TRUE;
+}
+
+void
+_gypsy_message (const char *format, ...)
+{
+ va_list ap;
+
+ va_start (ap, format);
+ g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, format, ap);
+ va_end (ap);
+}
+
int
main (int argc,
char **argv)
@@ -98,14 +124,24 @@ main (int argc,
gboolean become_daemon = FALSE;
char *pidfile = NULL;
char *user_pidfile = NULL;
+ const char *env_string;
GOptionEntry entries[] = {
{ "nmea-log", 0, 0, G_OPTION_ARG_FILENAME, &nmea_log, "Log NMEA data to FILE.[device]", "FILE" },
{ "no-daemon", 0, 0, G_OPTION_ARG_NONE, &become_daemon, "Don't become a daemon", NULL },
{ "pid-file", 0, 0, G_OPTION_ARG_FILENAME, &user_pidfile, "Specify the location of a PID file", "FILE" },
+ { "gypsy-debug", 0, 0, G_OPTION_ARG_CALLBACK, gypsy_arg_debug_cb, "Gypsy debugging flags to set", "FLAGS" },
{ NULL }
};
+ env_string = g_getenv ("GYPSY_DEBUG");
+ if (env_string != NULL) {
+ gypsy_debug_flags = g_parse_debug_string
+ (env_string, gypsy_debug_keys,
+ G_N_ELEMENTS (gypsy_debug_keys));
+ env_string = NULL;
+ }
+
context = g_option_context_new ("- GPS daemon");
g_option_context_add_main_entries (context, entries, NULL);