diff --git a/girepository/src/compiler.c b/girepository/src/compiler.c index ba19ffda5..e374b1ca8 100644 --- a/girepository/src/compiler.c +++ b/girepository/src/compiler.c @@ -31,10 +31,11 @@ gboolean raw = FALSE; gboolean no_init = FALSE; -gboolean debug = FALSE; gchar **input = NULL; gchar *output = NULL; gchar *mname = NULL; +gboolean debug = FALSE; +gboolean verbose = FALSE; static gchar * format_output (guchar *metadata, @@ -126,6 +127,18 @@ write_out_metadata (gchar *prefix, fclose (file); } +GLogLevelFlags logged_levels; + +static void log_handler (const gchar *log_domain, + GLogLevelFlags log_level, + const gchar *message, + gpointer user_data) +{ + + if (log_level & logged_levels) + g_log_default_handler (log_domain, log_level, message, user_data); +} + static GOptionEntry options[] = { { "raw", 0, 0, G_OPTION_ARG_NONE, &raw, "emit raw metadata", NULL }, @@ -134,19 +147,11 @@ static GOptionEntry options[] = { "output", 'o', 0, G_OPTION_ARG_FILENAME, &output, "output file", "FILE" }, { "module", 'm', 0, G_OPTION_ARG_STRING, &mname, "module to compile", "NAME" }, { "debug", 0, 0, G_OPTION_ARG_NONE, &debug, "show debug messages", NULL }, + { "verbose", 0, 0, G_OPTION_ARG_NONE, &verbose, "show verbose messages", NULL }, { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &input, NULL, NULL }, { NULL, } }; -static void log_handler (const gchar *log_domain, - GLogLevelFlags log_level, - const gchar *message, - gpointer user_data) -{ - if (debug || log_level & G_LOG_LEVEL_DEBUG == 0) - g_log_default_handler (log_domain, log_level, message, user_data); -} - int main (int argc, char ** argv) { @@ -162,6 +167,12 @@ main (int argc, char ** argv) g_option_context_parse (context, &argc, &argv, &error); g_option_context_free (context); + logged_levels = G_LOG_LEVEL_MASK & ~(G_LOG_LEVEL_MESSAGE|G_LOG_LEVEL_DEBUG); + if (debug) + logged_levels = logged_levels | G_LOG_LEVEL_DEBUG; + if (verbose) + logged_levels = logged_levels | G_LOG_LEVEL_MESSAGE; + g_log_set_default_handler (log_handler, NULL); if (!input)