From: Sebastian Harl Date: Tue, 4 Nov 2014 22:35:27 +0000 (+0100) Subject: utils/error: Added sdb_vlog(). X-Git-Tag: sysdb-0.6.0~29 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=1d982887a503ce3ec7eae9695dbaa38d2db09bba;p=sysdb.git utils/error: Added sdb_vlog(). This function is like sdb_log() but accept a va_list. --- diff --git a/src/include/utils/error.h b/src/include/utils/error.h index 2c3df32..49034eb 100644 --- a/src/include/utils/error.h +++ b/src/include/utils/error.h @@ -37,6 +37,7 @@ #ifndef SDB_UTILS_ERROR_H #define SDB_UTILS_ERROR_H 1 +#include #include #ifdef __cplusplus @@ -71,7 +72,7 @@ void sdb_error_set_logger(int (*f)(int, const char *)); /* - * sdb_log: + * sdb_log, sdb_vlog: * Log the specified message. The string will be formatted in printf-style * using the specified format and arguments and logged with the specified * priority. In addition, the error message will be stored as the current @@ -82,6 +83,8 @@ sdb_error_set_logger(int (*f)(int, const char *)); int sdb_log(int prio, const char *fmt, ...) __attribute__((format(printf, 2, 3))); +int +sdb_vlog(int prio, const char *fmt, va_list ap); /* * sdb_error_set, sdb_error_append: diff --git a/src/utils/error.c b/src/utils/error.c index f40e31a..f4ff99a 100644 --- a/src/utils/error.c +++ b/src/utils/error.c @@ -195,13 +195,19 @@ sdb_log(int prio, const char *fmt, ...) int ret; va_start(ap, fmt); - ret = sdb_error_vprintf(fmt, ap); + ret = sdb_vlog(prio, fmt, ap); va_end(ap); + return ret; +} /* sdb_log */ +int +sdb_vlog(int prio, const char *fmt, va_list ap) +{ + int ret = sdb_error_vprintf(fmt, ap); if (ret > 0) sdb_do_log(prio); return ret; -} /* sdb_log */ +} /* sdb_vlog */ int sdb_error_set(const char *fmt, ...)