From e9d8eeedefa8adf47646ab9375c8888506f143e6 Mon Sep 17 00:00:00 2001 From: George Kiagiadakis Date: Sat, 9 Mar 2024 15:54:33 +0200 Subject: [PATCH] log.h: define G_LOG_DOMAIN only if WP_USE_LOCAL_LOG_TOPIC_IN_G_LOG is defined Define WP_USE_LOCAL_LOG_TOPIC_IN_G_LOG in project scope, so that we always use this feature in our codebase without causing problems for other projects. Fixes #571 --- lib/wp/log.h | 8 +++++--- meson.build | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/wp/log.h b/lib/wp/log.h index c47d4ad1..9f440ff1 100644 --- a/lib/wp/log.h +++ b/lib/wp/log.h @@ -59,10 +59,12 @@ struct _WpLogTopic { WP_LOG_TOPIC_STATIC(WP_LOCAL_LOG_TOPIC, t) /* make glib log functions also use the local log topic */ -#ifdef G_LOG_DOMAIN -# undef G_LOG_DOMAIN +#ifdef WP_USE_LOCAL_LOG_TOPIC_IN_G_LOG +# ifdef G_LOG_DOMAIN +# undef G_LOG_DOMAIN +# endif +# define G_LOG_DOMAIN (WP_LOCAL_LOG_TOPIC->topic_name) #endif -#define G_LOG_DOMAIN (WP_LOCAL_LOG_TOPIC->topic_name) WP_API void wp_log_topic_init (WpLogTopic *topic); diff --git a/meson.build b/meson.build index f48b1c3f..3b21710d 100644 --- a/meson.build +++ b/meson.build @@ -137,6 +137,7 @@ add_project_arguments(cc.get_supported_arguments(common_flags), language: 'c') common_args = [ '-D_GNU_SOURCE', '-DG_LOG_USE_STRUCTURED', + '-DWP_USE_LOCAL_LOG_TOPIC_IN_G_LOG', ] add_project_arguments(common_args, language: 'c')