diff options
author | Andre Lorbach <alorbach@adiscon.com> | 2008-02-11 10:25:18 +0000 |
---|---|---|
committer | Andre Lorbach <alorbach@adiscon.com> | 2008-02-11 10:25:18 +0000 |
commit | c1a8908b1e508dbd8760b17afd02666ef62b2fbc (patch) | |
tree | 830c97c4818cc97153ec40511335e2db4d126442 /syslogd.c | |
parent | a2785882aa50b5a8d7ff2a5f59a5eb995ad7491e (diff) | |
download | rsyslog-c1a8908b1e508dbd8760b17afd02666ef62b2fbc.tar.gz rsyslog-c1a8908b1e508dbd8760b17afd02666ef62b2fbc.tar.xz rsyslog-c1a8908b1e508dbd8760b17afd02666ef62b2fbc.zip |
Added debug function logerrorVar, which can have variable number of
parameters. Replaced debug prints in omsnmp with logerrorVar where
needed.
Diffstat (limited to 'syslogd.c')
-rw-r--r-- | syslogd.c | 26 |
1 files changed, 26 insertions, 0 deletions
@@ -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) |