[mutter] build: Make each executable/library have their own log domain



commit 70ab4b651971ac868c8c461eac30cb5653ae1f7f
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Thu Apr 28 16:09:11 2022 +0200

    build: Make each executable/library have their own log domain
    
    This helps reading log output during, as it's otherwise often unclear
    whether a log entry came from a test client or mutter itself.
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2391>

 src/meson.build                      | 16 ++++++++++++----
 src/tests/boxes-tests.c              |  6 +++---
 src/tests/meson.build                | 30 ++++++++++++++++++++++++------
 src/tests/monitor-store-unit-tests.c | 18 +++++++++---------
 src/tests/monitor-unit-tests.c       | 10 +++++-----
 src/tests/ref-test-sanity.c          |  2 +-
 src/tests/wayland-unit-tests.c       |  6 +++---
 7 files changed, 57 insertions(+), 31 deletions(-)
---
diff --git a/src/meson.build b/src/meson.build
index 7b456f524f..13a69c1a63 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -163,7 +163,6 @@ mutter_c_args = [
   '-DCOGL_ENABLE_MUTTER_API',
   '-DCLUTTER_DISABLE_DEPRECATION_WARNINGS',
   '-DCOGL_DISABLE_DEPRECATION_WARNINGS',
-  '-DG_LOG_DOMAIN="mutter"',
   '-DSN_API_NOT_YET_FROZEN=1',
   '-DGETTEXT_PACKAGE="@0@"'.format(meson.project_name()),
 ]
@@ -1023,7 +1022,10 @@ libmutter = shared_library(libmutter_name,
   soversion: 0,
   gnu_symbol_visibility: 'hidden',
   include_directories: mutter_includes,
-  c_args: mutter_c_args,
+  c_args: [
+    mutter_c_args,
+    '-DG_LOG_DOMAIN="libmutter"',
+  ],
   dependencies: [
     libmutter_cogl_dep,
     libmutter_clutter_dep,
@@ -1049,7 +1051,10 @@ executable('mutter',
     files('core/mutter.c'),
   ],
   include_directories: mutter_includes,
-  c_args: mutter_c_args,
+  c_args: [
+    mutter_c_args,
+    '-DG_LOG_DOMAIN="mutter"',
+  ],
   dependencies: [libmutter_dep],
   install_dir: bindir,
   install: true,
@@ -1062,7 +1067,10 @@ executable('mutter-restart-helper',
   include_directories: [
     top_includepath,
   ],
-  c_args: mutter_c_args,
+  c_args: [
+    mutter_c_args,
+    '-DG_LOG_DOMAIN="mutter-restart-helper"',
+  ],
   dependencies: [
     x11_dep,
     xcomposite_dep,
diff --git a/src/tests/boxes-tests.c b/src/tests/boxes-tests.c
index 8886a294cf..b0cad23626 100644
--- a/src/tests/boxes-tests.c
+++ b/src/tests/boxes-tests.c
@@ -653,7 +653,7 @@ test_regions_okay (void)
   /*************************************************************/
   /* Make sure test region 5 has the right spanning rectangles */
   /*************************************************************/
-  g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
+  g_test_expect_message ("libmutter", G_LOG_LEVEL_WARNING,
                          "Region to merge was empty!*");
   region = get_screen_region (5);
   g_test_assert_expected_messages ();
@@ -762,7 +762,7 @@ test_clamping_to_region (void)
   rect = meta_rect (50, 50, 10000, 10000);
   min_size.width = 600;  min_size.height = 1170;
 
-  g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
+  g_test_expect_message ("libmutter", G_LOG_LEVEL_WARNING,
                          "No rect whose size to clamp to found*");
   meta_rectangle_clamp_to_fit_into_region (region,
                                            fixed_directions,
@@ -794,7 +794,7 @@ test_clamping_to_region (void)
   min_size.width = 100;  min_size.height = 200;
   fixed_directions = FIXED_DIRECTION_Y;
 
-  g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
+  g_test_expect_message ("libmutter", G_LOG_LEVEL_WARNING,
                          "No rect whose size to clamp to found*");
   meta_rectangle_clamp_to_fit_into_region (region,
                                            fixed_directions,
diff --git a/src/tests/meson.build b/src/tests/meson.build
index 2cb05d9668..cada89d722 100644
--- a/src/tests/meson.build
+++ b/src/tests/meson.build
@@ -38,7 +38,10 @@ libmutter_test = shared_library(libmutter_test_name,
                                 mutter_test_sources,
                                 gnu_symbol_visibility: 'hidden',
                                 include_directories: tests_includes,
-                                c_args: tests_c_args,
+                                c_args: [
+                                  tests_c_args,
+                                  '-DG_LOG_DOMAIN="libmutter-test"',
+                                ],
                                 dependencies: tests_deps,
                                 install_rpath: pkglibdir,
                                 install_dir: libdir,
@@ -104,7 +107,10 @@ endforeach
 test_client = executable('mutter-test-client',
   sources: ['test-client.c'],
   include_directories: tests_includes,
-  c_args: tests_c_args,
+  c_args: [
+    tests_c_args,
+    '-DG_LOG_DOMAIN="mutter-test-client"',
+  ],
   dependencies: [
     gtk3_dep,
     gio_unix_dep,
@@ -120,7 +126,10 @@ test_runner = executable('mutter-test-runner',
     'test-runner.c',
   ],
   include_directories: tests_includes,
-  c_args: tests_c_args,
+  c_args: [
+    tests_c_args,
+    '-DG_LOG_DOMAIN="mutter-test-runner"',
+  ],
   dependencies: libmutter_test_dep,
   install: have_installed_tests,
   install_dir: mutter_installed_tests_libexecdir,
@@ -202,7 +211,10 @@ if have_native_tests
       dbus_screen_cast_built_sources,
     ],
     include_directories: tests_includes,
-    c_args: tests_c_args,
+    c_args: [
+      tests_c_args,
+      '-DG_LOG_DOMAIN="mutter-screen-cast-client"',
+    ],
     dependencies: [
       gio_dep,
       libpipewire_dep,
@@ -289,7 +301,10 @@ if have_native_tests
     test_executable = executable('mutter-' + test_case['name'],
       sources: test_case['sources'],
       include_directories: tests_includes,
-      c_args: tests_c_args,
+      c_args: [
+        tests_c_args,
+        '-DG_LOG_DOMAIN="mutter-@0@-test"'.format(test_case['name']),
+      ],
       dependencies: libmutter_test_dep,
       install: have_installed_tests,
       install_dir: mutter_installed_tests_libexecdir,
@@ -352,7 +367,10 @@ if have_kvm_tests or have_tty_tests
     test_executable = executable('mutter-' + test_case['name'],
       sources: test_case['sources'],
       include_directories: tests_includes,
-      c_args: tests_c_args,
+      c_args: [
+        tests_c_args,
+        '-DG_LOG_DOMAIN="mutter-@0@-test"'.format(test_case['name']),
+      ],
       dependencies: libmutter_test_dep,
       install: have_installed_tests,
       install_dir: mutter_installed_tests_libexecdir,
diff --git a/src/tests/monitor-store-unit-tests.c b/src/tests/monitor-store-unit-tests.c
index 004d466c9d..38f4bc52fc 100644
--- a/src/tests/monitor-store-unit-tests.c
+++ b/src/tests/monitor-store-unit-tests.c
@@ -876,13 +876,13 @@ meta_test_monitor_store_unknown_elements (void)
     .n_configurations = 1
   };
 
-  g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
+  g_test_expect_message ("libmutter", G_LOG_LEVEL_WARNING,
                          "Unknown element <unknownundermonitors> "
                          "under <monitors>, ignoring");
-  g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
+  g_test_expect_message ("libmutter", G_LOG_LEVEL_WARNING,
                          "Unknown element <unknownunderconfiguration> "
                          "under <configuration>, ignoring");
-  g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
+  g_test_expect_message ("libmutter", G_LOG_LEVEL_WARNING,
                          "Unknown element <unknownunderlogicalmonitor> "
                          "under <logicalmonitor>, ignoring");
   meta_set_custom_monitor_config (test_context, "unknown-elements.xml");
@@ -894,7 +894,7 @@ meta_test_monitor_store_unknown_elements (void)
 static void
 meta_test_monitor_store_policy_not_allowed (void)
 {
-  g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
+  g_test_expect_message ("libmutter-test", G_LOG_LEVEL_WARNING,
                          "*Policy can only be defined in system level "
                          "configurations*");
   meta_set_custom_monitor_config (test_context, "policy.xml");
@@ -923,7 +923,7 @@ meta_test_monitor_store_policy (void)
 static void
 meta_test_monitor_store_policy_empty (void)
 {
-  g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
+  g_test_expect_message ("libmutter-test", G_LOG_LEVEL_WARNING,
                          "*Invalid store*");
   meta_set_custom_monitor_system_config (test_context, "policy-empty.xml");
   g_test_assert_expected_messages ();
@@ -932,7 +932,7 @@ meta_test_monitor_store_policy_empty (void)
 static void
 meta_test_monitor_store_policy_duplicate (void)
 {
-  g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
+  g_test_expect_message ("libmutter-test", G_LOG_LEVEL_WARNING,
                          "*Multiple identical stores*");
   meta_set_custom_monitor_system_config (test_context, "policy-duplicate.xml");
   g_test_assert_expected_messages ();
@@ -941,7 +941,7 @@ meta_test_monitor_store_policy_duplicate (void)
 static void
 meta_test_monitor_store_policy_invalid (void)
 {
-  g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
+  g_test_expect_message ("libmutter-test", G_LOG_LEVEL_WARNING,
                          "*Invalid store*");
   meta_set_custom_monitor_system_config (test_context, "policy-invalid.xml");
   g_test_assert_expected_messages ();
@@ -950,7 +950,7 @@ meta_test_monitor_store_policy_invalid (void)
 static void
 meta_test_monitor_store_policy_multiple (void)
 {
-  g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
+  g_test_expect_message ("libmutter-test", G_LOG_LEVEL_WARNING,
                          "*Multiple stores elements under policy*");
   meta_set_custom_monitor_system_config (test_context, "policy-multiple.xml");
   g_test_assert_expected_messages ();
@@ -991,7 +991,7 @@ meta_test_monitor_store_policy_dbus_invalid (void)
     meta_monitor_config_manager_get_store (config_manager);
   const MetaMonitorConfigPolicy *policy;
 
-  g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
+  g_test_expect_message ("libmutter-test", G_LOG_LEVEL_WARNING,
                          "*Multiple dbus elements under policy*");
   meta_set_custom_monitor_system_config (test_context,
                                          "policy-dbus-invalid.xml");
diff --git a/src/tests/monitor-unit-tests.c b/src/tests/monitor-unit-tests.c
index 7a19ca1134..6a807c60e3 100644
--- a/src/tests/monitor-unit-tests.c
+++ b/src/tests/monitor-unit-tests.c
@@ -1852,7 +1852,7 @@ meta_test_monitor_suggested_config_overlapping (void)
                                                &test_case.setup,
                                                MONITOR_TEST_FLAG_NO_STORED);
 
-  g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
+  g_test_expect_message ("libmutter", G_LOG_LEVEL_WARNING,
                          "Suggested monitor config has overlapping region, "
                          "rejecting");
   emulate_hotplug (test_setup);
@@ -2011,7 +2011,7 @@ meta_test_monitor_suggested_config_not_adjacent (void)
                                                &test_case.setup,
                                                MONITOR_TEST_FLAG_NO_STORED);
 
-  g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
+  g_test_expect_message ("libmutter", G_LOG_LEVEL_WARNING,
                          "Suggested monitor config has monitors with no "
                          "neighbors, rejecting");
   emulate_hotplug (test_setup);
@@ -2169,7 +2169,7 @@ meta_test_monitor_suggested_config_multi_dpi (void)
                                                &test_case.setup,
                                                MONITOR_TEST_FLAG_NO_STORED);
 
-  g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
+  g_test_expect_message ("libmutter", G_LOG_LEVEL_WARNING,
                          "Suggested monitor config has monitors with no "
                          "neighbors, rejecting");
   emulate_hotplug (test_setup);
@@ -2298,7 +2298,7 @@ meta_test_monitor_limited_crtcs (void)
                                                &test_case.setup,
                                                MONITOR_TEST_FLAG_NO_STORED);
 
-  g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
+  g_test_expect_message ("libmutter", G_LOG_LEVEL_WARNING,
                          "Failed to use linear *");
 
   emulate_hotplug (test_setup);
@@ -7992,7 +7992,7 @@ meta_test_monitor_migrated_wiggle_discard (void)
                                          &error))
     g_error ("Failed to migrate config: %s", error->message);
 
-  g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
+  g_test_expect_message ("libmutter", G_LOG_LEVEL_WARNING,
                          "Failed to finish monitors config migration: "
                          "Mode not available on monitor");
   emulate_hotplug (test_setup);
diff --git a/src/tests/ref-test-sanity.c b/src/tests/ref-test-sanity.c
index d9dd32c6c8..0776270da9 100644
--- a/src/tests/ref-test-sanity.c
+++ b/src/tests/ref-test-sanity.c
@@ -106,7 +106,7 @@ meta_test_ref_test_sanity (void)
   clutter_actor_set_background_color (actor2, CLUTTER_COLOR_SkyBlue);
   clutter_actor_add_child (stage, actor2);
 
-  g_test_expect_message (G_LOG_DOMAIN,
+  g_test_expect_message ("libmutter-test",
                          G_LOG_LEVEL_CRITICAL,
                          "Pixel difference exceeds limits*");
 
diff --git a/src/tests/wayland-unit-tests.c b/src/tests/wayland-unit-tests.c
index 9c42b16332..116531ba4e 100644
--- a/src/tests/wayland-unit-tests.c
+++ b/src/tests/wayland-unit-tests.c
@@ -82,9 +82,9 @@ subsurface_invalid_subsurfaces (void)
 
   wayland_test_client =
     meta_wayland_test_client_new ("invalid-subsurfaces");
-  g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
+  g_test_expect_message ("libmutter", G_LOG_LEVEL_WARNING,
                          "WL: error in client communication*");
-  g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
+  g_test_expect_message ("libmutter", G_LOG_LEVEL_WARNING,
                          "WL: error in client communication*");
   meta_wayland_test_client_finish (wayland_test_client);
   g_test_assert_expected_messages ();
@@ -97,7 +97,7 @@ subsurface_invalid_xdg_shell_actions (void)
 
   wayland_test_client =
     meta_wayland_test_client_new ("invalid-xdg-shell-actions");
-  g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
+  g_test_expect_message ("libmutter", G_LOG_LEVEL_WARNING,
                          "Invalid geometry * set on xdg_surface*");
   meta_wayland_test_client_finish (wayland_test_client);
   g_test_assert_expected_messages ();


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