Skip to content

Commit

Permalink
Merge pull request #82 from ejoerns/topic/debug-option
Browse files Browse the repository at this point in the history
Add support for --debug option
  • Loading branch information
jluebbe committed Nov 18, 2016
2 parents 39b9d12 + a50f46c commit ac07bf9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ CODE_COVERAGE_IGNORE_PATTERN = "*-generated.c"
@CODE_COVERAGE_RULES@
@VALGRIND_CHECK_RULES@

AM_CFLAGS = $(WARN_CFLAGS) $(GLIB_CFLAGS) $(CURL_CFLAGS)
AM_CFLAGS = -DG_LOG_DOMAIN=\"rauc\" $(WARN_CFLAGS) $(GLIB_CFLAGS) $(CURL_CFLAGS)
AM_LDFLAGS = $(WARN_LDFLAGS) $(GLIB_LDFLAGS) $(CURL_LDFLAGS) $(OPENSSL_LDFLAGS)
AM_CPPFLAGS = -I${top_srcdir}/include $(OPENSSL_INCLUDES)

Expand Down
16 changes: 15 additions & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,7 @@ GOptionEntry entries_status[] = {

static void cmdline_handler(int argc, char **argv)
{
gboolean help = FALSE, version = FALSE;
gboolean help = FALSE, debug = FALSE, version = FALSE;
gchar *confpath = NULL, *certpath = NULL, *keypath = NULL, *mount = NULL,
*handlerextra = NULL;
char *cmdarg = NULL;
Expand All @@ -781,6 +781,7 @@ static void cmdline_handler(int argc, char **argv)
{"key", '\0', 0, G_OPTION_ARG_FILENAME, &keypath, "key file", "PEMFILE"},
{"mount", '\0', 0, G_OPTION_ARG_FILENAME, &mount, "mount prefix", "PATH"},
{"handler-args", '\0', 0, G_OPTION_ARG_STRING, &handlerextra, "extra handler arguments", "ARGS"},
{"debug", 'd', 0, G_OPTION_ARG_NONE, &debug, "enable debug output", NULL},
{"version", '\0', 0, G_OPTION_ARG_NONE, &version, "display version", NULL},
{"help", 'h', 0, G_OPTION_ARG_NONE, &help, NULL, NULL},
{0}
Expand Down Expand Up @@ -829,6 +830,19 @@ static void cmdline_handler(int argc, char **argv)
goto done;
}

if (debug) {
const gchar *domains = g_getenv("G_MESSAGES_DEBUG");
if (!domains) {
g_assert(g_setenv("G_MESSAGES_DEBUG", G_LOG_DOMAIN, TRUE));
} else if (!g_str_equal(domains, "all") && !g_strrstr(domains, G_LOG_DOMAIN)) {
gchar *newdomains = g_strdup_printf("%s %s", domains, G_LOG_DOMAIN);
g_setenv("G_MESSAGES_DEBUG", newdomains, TRUE);
g_free(newdomains);
}
domains = g_getenv("G_MESSAGES_DEBUG");
g_print("Domains: '%s'\n", domains);
}

/* get first parameter wihtout dashes */
for (gint i = 1; i <= argc; i++) {
if (argv[i] && !g_str_has_prefix (argv[i], "-")) {
Expand Down

0 comments on commit ac07bf9

Please sign in to comment.