diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-03-23 15:26:57 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-03-23 15:26:57 +0000 |
commit | f07041e17635e7ba0bcbb0adddc61059b5f510eb (patch) | |
tree | a77a32b580beb372ea29353ddc63fda6ef951702 /src/libutil/printf.c | |
parent | 2b584275d8aae7634204e047168e83f4b580ec42 (diff) | |
download | rspamd-f07041e17635e7ba0bcbb0adddc61059b5f510eb.tar.gz rspamd-f07041e17635e7ba0bcbb0adddc61059b5f510eb.zip |
Add %e modifier for GError clever printing.
Diffstat (limited to 'src/libutil/printf.c')
-rw-r--r-- | src/libutil/printf.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/libutil/printf.c b/src/libutil/printf.c index 5a04dc432..0cd043058 100644 --- a/src/libutil/printf.c +++ b/src/libutil/printf.c @@ -339,6 +339,7 @@ rspamd_vprintf_common (rspamd_printf_append_func func, guint width, sign, hex, humanize, bytes, frac_width, i; rspamd_fstring_t *v; GString *gs; + GError *err; gboolean bv; while (*fmt) { @@ -462,6 +463,24 @@ rspamd_vprintf_common (rspamd_printf_append_func func, continue; + case 'e': + err = va_arg (args, GError *); + + if (err) { + p = err->message; + + if (p == NULL) { + p = "(NULL)"; + } + } + else { + p = "unknown error"; + } + + slen = strlen (p); + RSPAMD_PRINTF_APPEND (p, slen); + break; + case 's': p = va_arg (args, gchar *); if (p == NULL) { |