mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-02 17:26:17 +01:00
Add a --verbose cmdline option and only log messages if it is specified.
2005-05-11 Matthias Clasen <mclasen@redhat.com> * src/compiler.c (main): Add a --verbose cmdline option and only log messages if it is specified. * src/gidlnode.h: * src/gidlnode.c (init_stats, dump_stats): Collect some statistics on string and type sharing. * src/gidlmodule.c (g_idl_module_build_metadata): Use g_message() instead of fprintf(). * src/gidlnode.c (g_idl_node_free): Make this more robust. (g_idl_node_get_size): Implement for structs. (g_idl_node_get_full_size): Handle parent being NULL. (serialize_type): Handle lookup failures more gracefully.
This commit is contained in:
parent
4d84e48c1a
commit
18f3b27fa0
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user