Make --verbose a counting argument, specify twice for more info

Closes: #1077
Approved by: alexlarsson
This commit is contained in:
Alexander Larsson
2017-10-04 15:24:34 +02:00
committed by Atomic Bot
parent 6c15539f06
commit aec35fd9d9
3 changed files with 34 additions and 3 deletions

View File

@@ -33,7 +33,7 @@
#include "flatpak-builtins.h"
#include "flatpak-utils.h"
static gboolean opt_verbose;
static int opt_verbose;
static gboolean opt_ostree_verbose;
static gboolean opt_version;
static gboolean opt_default_arch;
@@ -104,8 +104,19 @@ static FlatpakCommand commands[] = {
{ NULL }
};
static gboolean
opt_verbose_cb (const gchar *option_name,
const gchar *value,
gpointer data,
GError **error)
{
opt_verbose++;
return TRUE;
}
GOptionEntry global_entries[] = {
{ "verbose", 'v', 0, G_OPTION_ARG_NONE, &opt_verbose, N_("Print debug information during command processing"), NULL },
{ "verbose", 'v', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, &opt_verbose_cb, N_("Print debug information during command processing, -vv for more detail"), NULL },
{ "ostree-verbose", 0, 0, G_OPTION_ARG_NONE, &opt_ostree_verbose, N_("Print OSTree debug information during command processing"), NULL },
{ "help", '?', G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, N_("Show help options"), NULL, NULL },
{ NULL }
@@ -224,8 +235,10 @@ flatpak_option_context_parse (GOptionContext *context,
/* We never want verbose output in the complete case, that breaks completion */
if (!is_in_complete)
{
if (opt_verbose)
if (opt_verbose > 0)
g_log_set_handler (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, message_handler, NULL);
if (opt_verbose > 1)
g_log_set_handler (G_LOG_DOMAIN "2", G_LOG_LEVEL_DEBUG, message_handler, NULL);
if (opt_ostree_verbose)
g_log_set_handler ("OSTree", G_LOG_LEVEL_DEBUG, message_handler, NULL);

View File

@@ -77,6 +77,22 @@ flatpak_error_quark (void)
return (GQuark) quark_volatile;
}
void
flatpak_debug2 (const char *format, ...)
{
va_list var_args;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat-nonliteral"
va_start (var_args, format);
g_logv (G_LOG_DOMAIN"2",
G_LOG_LEVEL_DEBUG,
format, var_args);
va_end (var_args);
#pragma GCC diagnostic pop
}
GFile *
flatpak_file_new_tmp_in (GFile *dir,
const char *template,

View File

@@ -61,6 +61,8 @@ typedef void (*FlatpakLoadUriProgress) (guint64 downloaded_bytes,
*/
#define flatpak_fail glnx_throw
void flatpak_debug2 (const char *format, ...) G_GNUC_PRINTF(1, 2);
gint flatpak_strcmp0_ptr (gconstpointer a,
gconstpointer b);