[sysprof] libsysprof-capture: add sysprof_collector_log_printf()
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sysprof] libsysprof-capture: add sysprof_collector_log_printf()
- Date: Mon, 16 Mar 2020 19:28:30 +0000 (UTC)
commit 3d546eb6d1e0d790286fb9813d644a8591f00392
Author: Christian Hergert <chergert redhat com>
Date: Mon Mar 16 12:24:17 2020 -0700
libsysprof-capture: add sysprof_collector_log_printf()
This is a convenience function to call sysprof_collector_log() while also
formatting the message.
Ideally we'd be able to avoid the string format if we are not currently
collecting data, but that can be left for a future commit. We don't have
recursive locks so we need to duplicate the structure setup.
src/libsysprof-capture/sysprof-collector.c | 16 ++++++++++++++++
src/libsysprof-capture/sysprof-collector.h | 5 +++++
2 files changed, 21 insertions(+)
---
diff --git a/src/libsysprof-capture/sysprof-collector.c b/src/libsysprof-capture/sysprof-collector.c
index 985fee7..5f06dd3 100644
--- a/src/libsysprof-capture/sysprof-collector.c
+++ b/src/libsysprof-capture/sysprof-collector.c
@@ -454,3 +454,19 @@ sysprof_collector_log (GLogLevelFlags severity,
} COLLECTOR_END;
}
+
+void
+sysprof_collector_log_printf (GLogLevelFlags severity,
+ const gchar *domain,
+ const gchar *format,
+ ...)
+{
+ g_autofree gchar *formatted = NULL;
+ va_list args;
+
+ va_start (args, format);
+ formatted = g_strdup_vprintf (format, args);
+ va_end (args);
+
+ sysprof_collector_log (severity, domain, formatted);
+}
diff --git a/src/libsysprof-capture/sysprof-collector.h b/src/libsysprof-capture/sysprof-collector.h
index 6e1f9ed..68ac688 100644
--- a/src/libsysprof-capture/sysprof-collector.h
+++ b/src/libsysprof-capture/sysprof-collector.h
@@ -81,5 +81,10 @@ SYSPROF_AVAILABLE_IN_3_36
void sysprof_collector_log (GLogLevelFlags severity,
const gchar *domain,
const gchar *message);
+SYSPROF_AVAILABLE_IN_3_38
+void sysprof_collector_log_printf (GLogLevelFlags severity,
+ const gchar *domain,
+ const gchar *format,
+ ...) G_GNUC_PRINTF (3, 4);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]