gdebugcontroller: Add debug controller API and D-Bus implementation

This is intended to provide a uniform interface for controlling whether
the debug output from an application (or service) is emitted, typically
to journald, but actually to wherever the application chooses to output
it.

The main implementation of `GDebugController` is `GDebugControllerDBus`,
which is intended to be used on Linux. Other implementations may be
added in future for other platforms, or larger applications may want to
provide their own implementation which integrates with their ecosystem.

The `GDebugControllerDBus` implementation exposes a D-Bus interface at
`/org/gtk/Debugging` with a method to enable or disable debug
output at runtime.

This could be used by external harnesses, such as GNOME Builder or
systemd, to give a uniform way to get debug output from an application.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Fixes: #1190
This commit is contained in:
Philip Withnall
2021-11-11 10:56:50 +00:00
parent bb4bec0921
commit 0c8f7de55a
10 changed files with 815 additions and 0 deletions

View File

@@ -45,6 +45,8 @@
#include "gnotificationbackend.h"
#include "ginitable.h"
#include "gnetworkmonitor.h"
#include "gdebugcontroller.h"
#include "gdebugcontrollerdbus.h"
#include "gmemorymonitor.h"
#include "gmemorymonitorportal.h"
#include "gmemorymonitordbus.h"
@@ -1078,6 +1080,7 @@ extern GType _g_network_monitor_netlink_get_type (void);
extern GType _g_network_monitor_nm_get_type (void);
#endif
extern GType g_debug_controller_dbus_get_type (void);
extern GType g_memory_monitor_dbus_get_type (void);
extern GType g_memory_monitor_portal_get_type (void);
extern GType g_power_profile_monitor_dbus_get_type (void);
@@ -1189,6 +1192,9 @@ _g_io_modules_ensure_extension_points_registered (void)
ep = g_io_extension_point_register (G_NOTIFICATION_BACKEND_EXTENSION_POINT_NAME);
g_io_extension_point_set_required_type (ep, G_TYPE_NOTIFICATION_BACKEND);
ep = g_io_extension_point_register (G_DEBUG_CONTROLLER_EXTENSION_POINT_NAME);
g_io_extension_point_set_required_type (ep, G_TYPE_DEBUG_CONTROLLER);
ep = g_io_extension_point_register (G_MEMORY_MONITOR_EXTENSION_POINT_NAME);
g_io_extension_point_set_required_type (ep, G_TYPE_MEMORY_MONITOR);