From 220035746bdd5b6c01aa724dc711e6d97e1097dd Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Sun, 20 Mar 2011 00:21:56 -0700 Subject: [PATCH] Add va_list variants of the guac_log_* functions --- libguac/include/log.h | 32 ++++++++++++++++++++++++++++---- libguac/src/log.c | 42 +++++++++++++++++++++++++----------------- 2 files changed, 53 insertions(+), 21 deletions(-) diff --git a/libguac/include/log.h b/libguac/include/log.h index 273f6698..43fc7fcf 100644 --- a/libguac/include/log.h +++ b/libguac/include/log.h @@ -50,10 +50,22 @@ * log to syslog for platforms supporting it, and stderr for * all others. * - * @param str A printf-style format string to log. + * @param format A printf-style format string to log. * @param ... Arguments to use when filling the format string for printing. */ -void guac_log_info(const char* str, ...); +void guac_log_info(const char* format, ...); + +/** + * Logs an informational message in the system log, whatever + * that may be for the system being used. This will currently + * log to syslog for platforms supporting it, and stderr for + * all others. + * + * @param format A printf-style format string to log. + * @param ap The va_list containing the arguments to be used when filling the + * format string for printing. + */ +void vguac_log_info(const char* format, va_list ap); /** * Logs an error message in the system log, whatever @@ -61,9 +73,21 @@ void guac_log_info(const char* str, ...); * log to syslog for platforms supporting it, and stderr for * all others. * - * @param str A printf-style format string to log. + * @param format A printf-style format string to log. * @param ... Arguments to use when filling the format string for printing. */ -void guac_log_error(const char* str, ...); +void guac_log_error(const char* format, ...); + +/** + * Logs an error message in the system log, whatever + * that may be for the system being used. This will currently + * log to syslog for platforms supporting it, and stderr for + * all others. + * + * @param format A printf-style format string to log. + * @param ap The va_list containing the arguments to be used when filling the + * format string for printing. + */ +void vguac_log_error(const char* format, va_list ap); #endif diff --git a/libguac/src/log.c b/libguac/src/log.c index 46568678..c51bff15 100644 --- a/libguac/src/log.c +++ b/libguac/src/log.c @@ -45,35 +45,43 @@ #include "log.h" -void guac_log_info(const char* str, ...) { - - va_list args; - va_start(args, str); - +void vguac_log_info(const char* format, va_list ap) { #ifdef HAVE_SYSLOG_H - vsyslog(LOG_ERR, str, args); + vsyslog(LOG_ERR, format, ap); #else fprintf(stderr, "guacamole: info: "); - vfprintf(stderr, str, args); + vfprintf(stderr, format, ap); fprintf(stderr, "\n"); #endif - - va_end(args); - } -void guac_log_error(const char* str, ...) { - - va_list args; - va_start(args, str); - +void vguac_log_error(const char* format, va_list ap) { #ifdef HAVE_SYSLOG_H - vsyslog(LOG_INFO, str, args); + vsyslog(LOG_INFO, format, ap); #else fprintf(stderr, "guacamole: error: "); - vfprintf(stderr, str, args); + vfprintf(stderr, format, ap); fprintf(stderr, "\n"); #endif +} + +void guac_log_info(const char* format, ...) { + + va_list args; + va_start(args, format); + + vguac_log_info(format, args); + + va_end(args); + +} + +void guac_log_error(const char* format, ...) { + + va_list args; + va_start(args, format); + + vguac_log_error(format, args); va_end(args);