From d690fe5f68d8f98ec3b9bb95bf461bee02d3569c Mon Sep 17 00:00:00 2001
From: Evangelos Ribeiro Tzaras <devrtz@fortysixandtwo.eu>
Date: Sun, 29 Jan 2023 12:58:09 +0100
Subject: [PATCH] application: Handle setting verbosity first

We want logging verbosity to be set before other command line options
are handled as we might be missing messages otherwise.
---
 src/calls-application.c | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/src/calls-application.c b/src/calls-application.c
index 485fd9e..8b94959 100644
--- a/src/calls-application.c
+++ b/src/calls-application.c
@@ -516,6 +516,17 @@ calls_application_command_line (GApplication            *application,
 
   options = g_application_command_line_get_options_dict (command_line);
 
+  /* TODO make this a comma separated string of "CATEGORY:level" pairs */
+  if (g_variant_dict_lookup (options, "verbosity", "u", &verbosity)) {
+    gint delta = calls_log_set_verbosity (verbosity);
+    guint level = calls_log_get_verbosity ();
+    if (delta != 0)
+      g_print ("%s verbosity by %d to %u\n",
+               delta > 0 ? "Increased" : "Decreased",
+               delta < 0 ? -1 * delta : delta,
+               level);
+  }
+
   providers = g_variant_dict_lookup_value (options, "provider", G_VARIANT_TYPE_STRING_ARRAY);
   if (providers) {
     g_action_group_activate_action (G_ACTION_GROUP (application),
@@ -534,18 +545,6 @@ calls_application_command_line (GApplication            *application,
   if (g_variant_dict_lookup (options, "dial", "&s", &arg))
     g_action_group_activate_action (G_ACTION_GROUP (application),
                                     "dial", g_variant_new_string (arg));
-
-  /* TODO make this a comma separated string of "CATEGORY:level" pairs */
-  if (g_variant_dict_lookup (options, "verbosity", "u", &verbosity)) {
-    gint delta = calls_log_set_verbosity (verbosity);
-    guint level = calls_log_get_verbosity ();
-    if (delta != 0)
-      g_print ("%s verbosity by %d to %u\n",
-               delta > 0 ? "Increased" : "Decreased",
-               delta < 0 ? -1 * delta : delta,
-               level);
-  }
-
   arguments = g_application_command_line_get_arguments (command_line, &argc);
 
   /* Keep only the first URI, if there are many */