From c1a8908b1e508dbd8760b17afd02666ef62b2fbc Mon Sep 17 00:00:00 2001 From: Andre Lorbach Date: Mon, 11 Feb 2008 10:25:18 +0000 Subject: Added debug function logerrorVar, which can have variable number of parameters. Replaced debug prints in omsnmp with logerrorVar where needed. --- syslogd.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'syslogd.c') diff --git a/syslogd.c b/syslogd.c index 7434c8b7..de4c311e 100644 --- a/syslogd.c +++ b/syslogd.c @@ -2334,6 +2334,32 @@ void logerrorInt(char *type, int errCode) return; } +/* + * Error Output with variable number of parameters. + * This functions works pretty much like dbgprintf, + * except it logs an error. + */ +void logerrorVar(char *fmt, ...) +{ + va_list ap; + char buf[1024]; + size_t lenBuf; + + /* Format parameters */ + va_start(ap, fmt); + lenBuf = vsnprintf(buf, sizeof(buf), fmt, ap); + if(lenBuf >= sizeof(buf)) { + /* if our buffer was too small, we simply truncate. */ + lenBuf--; + } + va_end(ap); + + /* Log the error now */ + buf[sizeof(buf)/sizeof(char) - 1] = '\0'; /* just to be on the safe side... */ + logerror(buf); + return; +} + /* Print syslogd errors some place. */ void logerror(char *type) -- cgit v1.2.3