[gnome-builder/wip/gtk4-port] libide/foundry: add action to show verbose log output



commit 23a9c5259dded537bc6292ece7dbb5ba33052f53
Author: Christian Hergert <chergert redhat com>
Date:   Wed May 11 12:40:18 2022 -0700

    libide/foundry: add action to show verbose log output
    
    Now that we've removed all our use of G_MESSAGES_DEBUG after the initial
    startup within main(), we can make this toggleable for users in case they
    way to have additional logging such as durring debugging.
    
    We remove the "forced logging" when running the debugger as well.

 src/libide/debugger/ide-debug-manager.c |  3 ---
 src/libide/foundry/ide-run-manager.c    | 45 ++++++++++++++++++++++++++++-----
 src/plugins/buildui/gtk/menus.ui        | 10 ++++++++
 3 files changed, 48 insertions(+), 10 deletions(-)
---
diff --git a/src/libide/debugger/ide-debug-manager.c b/src/libide/debugger/ide-debug-manager.c
index b9d4fe6cd..d2ffeaca8 100644
--- a/src/libide/debugger/ide-debug-manager.c
+++ b/src/libide/debugger/ide-debug-manager.c
@@ -1020,9 +1020,6 @@ ide_debug_manager_start (IdeDebugManager  *self,
 
   environment = ide_runner_get_environment (runner);
 
-  /* TODO: Make this toggle-able */
-  ide_environment_setenv (environment, "G_MESSAGES_DEBUG", "all");
-
   if (self->stop_at_criticals)
     ide_environment_setenv (environment, "G_DEBUG", "fatal-criticals");
   else if (self->stop_at_warnings)
diff --git a/src/libide/foundry/ide-run-manager.c b/src/libide/foundry/ide-run-manager.c
index 8a9c171b9..73c9bc97b 100644
--- a/src/libide/foundry/ide-run-manager.c
+++ b/src/libide/foundry/ide-run-manager.c
@@ -64,6 +64,7 @@ struct _IdeRunManager
   guint64                  pending_last_change_seq;
 
   guint                    busy : 1;
+  guint                    messages_debug_all : 1;
 };
 
 typedef struct
@@ -73,18 +74,21 @@ typedef struct
   guint      active;
 } DiscoverState;
 
-static void initable_iface_init                      (GInitableIface *iface);
-static void ide_run_manager_actions_run              (IdeRunManager  *self,
-                                                      GVariant       *param);
-static void ide_run_manager_actions_run_with_handler (IdeRunManager  *self,
-                                                      GVariant       *param);
-static void ide_run_manager_actions_stop             (IdeRunManager  *self,
-                                                      GVariant       *param);
+static void initable_iface_init                        (GInitableIface *iface);
+static void ide_run_manager_actions_run                (IdeRunManager  *self,
+                                                        GVariant       *param);
+static void ide_run_manager_actions_run_with_handler   (IdeRunManager  *self,
+                                                        GVariant       *param);
+static void ide_run_manager_actions_stop               (IdeRunManager  *self,
+                                                        GVariant       *param);
+static void ide_run_manager_actions_messages_debug_all (IdeRunManager  *self,
+                                                        GVariant       *param);
 
 IDE_DEFINE_ACTION_GROUP (IdeRunManager, ide_run_manager, {
   { "run", ide_run_manager_actions_run },
   { "run-with-handler", ide_run_manager_actions_run_with_handler, "s" },
   { "stop", ide_run_manager_actions_stop },
+  { "messages-debug-all", ide_run_manager_actions_messages_debug_all, NULL, "false" },
 })
 
 G_DEFINE_TYPE_EXTENDED (IdeRunManager, ide_run_manager, IDE_TYPE_OBJECT, G_TYPE_FLAG_FINAL,
@@ -125,15 +129,26 @@ static void
 ide_run_manager_real_run (IdeRunManager *self,
                           IdeRunner     *runner)
 {
+  IDE_ENTRY;
+
   g_assert (IDE_IS_RUN_MANAGER (self));
   g_assert (IDE_IS_RUNNER (runner));
 
+  /* Setup G_MESSAGES_DEBUG environment variable if necessary */
+  if (self->messages_debug_all)
+    {
+      IdeEnvironment *env = ide_runner_get_environment (runner);
+      ide_environment_setenv (env, "G_MESSAGES_DEBUG", "all");
+    }
+
   /*
    * If the current handler has a callback specified (our default "run" handler
    * does not), then we need to allow that handler to prepare the runner.
    */
   if (self->handler != NULL && self->handler->handler != NULL)
     self->handler->handler (self, runner, self->handler->handler_data);
+
+  IDE_EXIT;
 }
 
 static void
@@ -1375,3 +1390,19 @@ _ide_run_manager_drop_caches (IdeRunManager *self)
 
   self->last_change_seq = 0;
 }
+
+static void
+ide_run_manager_actions_messages_debug_all (IdeRunManager *self,
+                                            GVariant      *param)
+{
+  IDE_ENTRY;
+
+  g_assert (IDE_IS_RUN_MANAGER (self));
+
+  self->messages_debug_all = !self->messages_debug_all;
+  ide_run_manager_set_action_state (self,
+                                    "messages-debug-all",
+                                    g_variant_new_boolean (self->messages_debug_all));
+
+  IDE_EXIT;
+}
diff --git a/src/plugins/buildui/gtk/menus.ui b/src/plugins/buildui/gtk/menus.ui
index f66d83bfe..807f97b70 100644
--- a/src/plugins/buildui/gtk/menus.ui
+++ b/src/plugins/buildui/gtk/menus.ui
@@ -157,6 +157,16 @@
           <attribute name="target" type="s">'rtl'</attribute>
         </item>
       </submenu>
+      <submenu id="run-menu-logging-submenu">
+        <attribute name="label" translatable="yes">Logging</attribute>
+        <section id="run-menu-logging-section">
+          <item>
+            <attribute name="label" translatable="yes">Verbose Log Output</attribute>
+            <attribute name="action">run-manager.messages-debug-all</attribute>
+            <attribute name="role">check</attribute>
+          </item>
+        </section>
+      </submenu>
     </section>
   </menu>
 </interface>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]