summaryrefslogtreecommitdiffstats
path: root/syslogd.c
diff options
context:
space:
mode:
authorAndre Lorbach <alorbach@adiscon.com>2008-02-11 10:25:18 +0000
committerAndre Lorbach <alorbach@adiscon.com>2008-02-11 10:25:18 +0000
commitc1a8908b1e508dbd8760b17afd02666ef62b2fbc (patch)
tree830c97c4818cc97153ec40511335e2db4d126442 /syslogd.c
parenta2785882aa50b5a8d7ff2a5f59a5eb995ad7491e (diff)
downloadrsyslog-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.c26
1 files changed, 26 insertions, 0 deletions
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)