[glib-networking/nacho/logging-define] tlslog: add meson config setting to log at debug level
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib-networking/nacho/logging-define] tlslog: add meson config setting to log at debug level
- Date: Tue, 17 May 2022 12:40:05 +0000 (UTC)
commit f31598c73c167574ea95b21939605a1f71b8abc3
Author: Ignacio Casal Quinteiro <qignacio amazon com>
Date: Fri May 13 15:20:09 2022 +0200
tlslog: add meson config setting to log at debug level
Otherwise this becomes expensive when doing lots of read/writes
and endups consuming quite a bit of CPU.
Partially fixes #188
Part-of: <https://gitlab.gnome.org/GNOME/glib-networking/-/merge_requests/210>
.gitlab-ci.yml | 3 +++
.gitlab-ci/test-msvc.bat | 2 +-
meson.build | 1 +
meson_options.txt | 1 +
tls/base/gtlslog.c | 65 +++++++++++++++++++++++++-----------------------
5 files changed, 40 insertions(+), 32 deletions(-)
---
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 40aa4afc..52cfe8a0 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -13,6 +13,7 @@ fedora-x86_64:
-Dopenssl=enabled
-Dlibproxy=enabled
-Dgnome_proxy=enabled
+ -Ddebug_logs=true
-Dwerror=true
_build/
- meson compile -C _build/
@@ -38,6 +39,7 @@ fedora-x86_64-asan:
-Dopenssl=enabled
-Dlibproxy=enabled
-Dgnome_proxy=enabled
+ -Ddebug_logs=true
-Dwerror=true
_build/
- meson compile -C _build/
@@ -54,6 +56,7 @@ fedora-x86_64-scan-build:
-Dopenssl=enabled
-Dlibproxy=enabled
-Dgnome_proxy=enabled
+ -Ddebug_logs=true
-Dwerror=true
_build/
- scan-build meson compile -C _build/
diff --git a/.gitlab-ci/test-msvc.bat b/.gitlab-ci/test-msvc.bat
index 66412b4f..da10623e 100644
--- a/.gitlab-ci/test-msvc.bat
+++ b/.gitlab-ci/test-msvc.bat
@@ -27,7 +27,7 @@ set PKG_CONFIG_PATH=%DEPS_DIR%\lib\pkgconfig
:: FIXME: make warnings fatal
pip3 install --upgrade --user meson==0.60.0 || goto :error
-meson build -Dgnutls=disabled -Dopenssl=enabled || goto :error
+meson build -Dgnutls=disabled -Dopenssl=enabled -Ddebug_logs=true || goto :error
ninja -C build || goto :error
meson test -C build --timeout-multiplier=10 || goto :error
diff --git a/meson.build b/meson.build
index 5335d890..754e1636 100644
--- a/meson.build
+++ b/meson.build
@@ -21,6 +21,7 @@ host_system = host_machine.system()
config_h = configuration_data()
config_h.set_quoted('GETTEXT_PACKAGE', meson.project_name())
+config_h.set10('ENABLE_DEBUG_LOGS', get_option('debug_logs'))
# compiler flags
common_flags = [
diff --git a/meson_options.txt b/meson_options.txt
index aaf62274..0621c52c 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -7,3 +7,4 @@ option('libproxy', type: 'feature', value: 'auto', description: 'support for lib
option('gnome_proxy', type: 'feature', value: 'auto', description: 'support for GNOME desktop proxy
configuration')
option('installed_tests', type: 'boolean', value: false, description: 'enable installed tests')
option('static_modules', type: 'boolean', value: false, description: 'build static modules')
+option('debug_logs', type: 'boolean', value: false, description: 'enable debug log messages')
diff --git a/tls/base/gtlslog.c b/tls/base/gtlslog.c
index cf3ab054..04baff36 100644
--- a/tls/base/gtlslog.c
+++ b/tls/base/gtlslog.c
@@ -39,40 +39,43 @@ void g_tls_log (GLogLevelFlags level,
const gchar *format,
...)
{
- gchar *header = NULL;
- gchar *message = NULL;
- gchar *thread = NULL;
- va_list args;
- int ret;
+ if (level < G_LOG_LEVEL_DEBUG || ENABLE_DEBUG_LOGS)
+ {
+ gchar *header = NULL;
+ gchar *message = NULL;
+ gchar *thread = NULL;
+ va_list args;
+ int ret;
- va_start (args, format);
- ret = g_vasprintf (&message, format, args);
- va_end (args);
+ va_start (args, format);
+ ret = g_vasprintf (&message, format, args);
+ va_end (args);
- if (ret <= 0)
- goto out;
+ if (ret <= 0)
+ goto out;
- if (conn && G_IS_TLS_CONNECTION (conn)) {
- if (G_IS_TLS_CLIENT_CONNECTION (conn))
- header = g_strdup_printf ("CLIENT[%p]: ", conn);
- else if (G_IS_TLS_SERVER_CONNECTION (conn))
- header = g_strdup_printf ("SERVER[%p]: ", conn);
- else
- g_assert_not_reached ();
- } else {
- header = g_strdup ("");
- }
+ if (conn && G_IS_TLS_CONNECTION (conn)) {
+ if (G_IS_TLS_CLIENT_CONNECTION (conn))
+ header = g_strdup_printf ("CLIENT[%p]: ", conn);
+ else if (G_IS_TLS_SERVER_CONNECTION (conn))
+ header = g_strdup_printf ("SERVER[%p]: ", conn);
+ else
+ g_assert_not_reached ();
+ } else {
+ header = g_strdup ("");
+ }
- thread = g_strdup_printf ("%p", g_thread_self ());
- g_log_structured (G_LOG_DOMAIN, level,
- "GLIB_NET_THREAD", thread,
- "CODE_FILE", file,
- "CODE_LINE", line,
- "CODE_FUNC", func,
- "MESSAGE", "%s%s", header, message);
+ thread = g_strdup_printf ("%p", g_thread_self ());
+ g_log_structured (G_LOG_DOMAIN, level,
+ "GLIB_NET_THREAD", thread,
+ "CODE_FILE", file,
+ "CODE_LINE", line,
+ "CODE_FUNC", func,
+ "MESSAGE", "%s%s", header, message);
-out:
- g_free (header);
- g_free (message);
- g_free (thread);
+ out:
+ g_free (header);
+ g_free (message);
+ g_free (thread);
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]