From 4a605f25824f51782322615399e696b4ed4e1332 Mon Sep 17 00:00:00 2001 From: Lukas Slebodnik Date: Mon, 11 Jan 2016 11:06:22 +0100 Subject: [PATCH 2/6] UTIL: Provide varargs version of debug_fn --- src/util/debug.c | 29 +++++++++++++++++++---------- src/util/util.h | 6 ++++++ 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/src/util/debug.c b/src/util/debug.c index c0a7732e90a1727f7c9514ad7ee6daf426b6075b..3dcfbf008b61d1611eb72e0ee0f1009a13dda6c4 100644 --- a/src/util/debug.c +++ b/src/util/debug.c @@ -206,13 +206,13 @@ journal_done: } #endif /* WiTH_JOURNALD */ -void sss_debug_fn(const char *file, - long line, - const char *function, - int level, - const char *format, ...) +void sss_vdebug_fn(const char *file, + long line, + const char *function, + int level, + const char *format, + va_list ap) { - va_list ap; struct timeval tv; struct tm *tm; char datetime[20]; @@ -230,10 +230,8 @@ void sss_debug_fn(const char *file, * can also provide extra structuring data to make it more easily * searchable. */ - va_start(ap, format); va_copy(ap_fallback, ap); ret = journal_send(file, line, function, level, format, ap); - va_end(ap); if (ret != EOK) { /* Emergency fallback, send to STDERR */ debug_vprintf(format, ap_fallback); @@ -266,12 +264,23 @@ void sss_debug_fn(const char *file, debug_prg_name, function, level); } - va_start(ap, format); debug_vprintf(format, ap); - va_end(ap); debug_fflush(); } +void sss_debug_fn(const char *file, + long line, + const char *function, + int level, + const char *format, ...) +{ + va_list ap; + + va_start(ap, format); + sss_vdebug_fn(file, line, function, level, format, ap); + va_end(ap); +} + void ldb_debug_messages(void *context, enum ldb_debug_level level, const char *fmt, va_list ap) { diff --git a/src/util/util.h b/src/util/util.h index 662d786ad362027e2f816688a02fd6fab36df14c..5df86b4cb084a01f31f3e11aaf3ffcbe79b996a9 100644 --- a/src/util/util.h +++ b/src/util/util.h @@ -77,6 +77,12 @@ extern int debug_microseconds; extern int debug_to_file; extern int debug_to_stderr; extern const char *debug_log_file; +void sss_vdebug_fn(const char *file, + long line, + const char *function, + int level, + const char *format, + va_list ap); void sss_debug_fn(const char *file, long line, const char *function, -- 2.5.0