diff options
author | Gaël Bonithon <gael@xfce.org> | 2021-12-29 18:18:28 +0100 |
---|---|---|
committer | Gaël Bonithon <gael@xfce.org> | 2021-12-29 18:51:59 +0100 |
commit | 87b66b4993c2d24a1d8a7274bc211efd901be855 (patch) | |
tree | f735c16640274511aa854c9316de0e533f32e5d3 /tumbler | |
parent | df92863d7d4b8d8e22a40af2495483410e47f45b (diff) | |
download | tumbler-87b66b4993c2d24a1d8a7274bc211efd901be855.tar.gz |
Debug: Display data side-by-side when appropriate
Diffstat (limited to 'tumbler')
-rw-r--r-- | tumbler/tumbler-util.c | 31 | ||||
-rw-r--r-- | tumbler/tumbler-util.h | 6 |
2 files changed, 37 insertions, 0 deletions
diff --git a/tumbler/tumbler-util.c b/tumbler/tumbler-util.c index 453e131..a8ea231 100644 --- a/tumbler/tumbler-util.c +++ b/tumbler/tumbler-util.c @@ -87,6 +87,37 @@ tumbler_util_dump_strv (const gchar *log_domain, +void +tumbler_util_dump_strvs_side_by_side (const gchar *log_domain, + const gchar *label_1, + const gchar *label_2, + const gchar *const *strv_1, + const gchar *const *strv_2) +{ + GString *string; + const gchar *const *p, *const *q; + + g_return_if_fail (label_1 != NULL && label_2 != NULL && strv_1 != NULL && strv_2 != NULL); + + if (! tumbler_util_is_debug_logging_enabled (log_domain)) + return; + + if (g_strv_length ((GStrv) strv_1) != g_strv_length ((GStrv) strv_2)) + g_warn_if_reached (); + + string = g_string_new (NULL); + g_string_append_printf (string, "%s | %s:\n", label_1, label_2); + + for (p = strv_1, q = strv_2; *p != NULL && *q != NULL; p++, q++) + g_string_append_printf (string, " %s | %s\n", *p, *q); + + g_string_truncate (string, string->len - 1); + g_log (log_domain, G_LOG_LEVEL_DEBUG, "%s", string->str); + g_string_free (string, TRUE); +} + + + /* * This is intended to be used around too verbose third-party APIs we can't silence by * another means: diff --git a/tumbler/tumbler-util.h b/tumbler/tumbler-util.h index e95d59a..686954c 100644 --- a/tumbler/tumbler-util.h +++ b/tumbler/tumbler-util.h @@ -34,6 +34,12 @@ void tumbler_util_dump_strv (const gchar *log_domain, const gchar *label, const gchar *const *strv); +void tumbler_util_dump_strvs_side_by_side (const gchar *log_domain, + const gchar *label_1, + const gchar *label_2, + const gchar *const *strv_1, + const gchar *const *strv_2); + void tumbler_util_toggle_stderr (const gchar *log_domain); gchar **tumbler_util_get_supported_uri_schemes (void) G_GNUC_MALLOC; |