summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2013-11-29 16:59:19 +0100
committerRainer Gerhards <rgerhards@adiscon.com>2013-11-29 16:59:19 +0100
commitc4501ebb5263b3b85bc6a854fcc3b6a35e94840a (patch)
tree8ecca199cfeba599e1465e4426b55ca9a67da3b0
parent56e2157bae6e5ad9e64ef672735a6e6e45e34312 (diff)
parenta98b1822a389cd209cb7a6660060abf995fbf715 (diff)
downloadrsyslog-c4501ebb5263b3b85bc6a854fcc3b6a35e94840a.tar.gz
rsyslog-c4501ebb5263b3b85bc6a854fcc3b6a35e94840a.tar.bz2
rsyslog-c4501ebb5263b3b85bc6a854fcc3b6a35e94840a.zip
Merge branch 'v7-devel' into tmp
Conflicts: action.c
-rw-r--r--ChangeLog7
-rw-r--r--action.c58
-rw-r--r--action.h9
-rw-r--r--dirty.h4
-rw-r--r--doc/Makefile.am1
-rw-r--r--doc/global.html41
-rw-r--r--doc/rainerscript.html3
-rw-r--r--runtime/errmsg.c98
-rw-r--r--runtime/errmsg.h9
-rw-r--r--runtime/glbl.c4
-rw-r--r--runtime/rsyslog.c19
-rw-r--r--runtime/rsyslog.h4
-rw-r--r--tools/syslogd.c15
13 files changed, 200 insertions, 72 deletions
diff --git a/ChangeLog b/ChangeLog
index ad634770..8bf7037b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -59,7 +59,14 @@ Version 8.1.0 [devel] 2013-11-15
just explicitely be given.
---------------------------------------------------------------------------
Version 7.5.8 [v7-devel] 2013-11-??
+- actions now report if they suspend and resume themselves
+ this is by default on and controllable by the action.reportSuspension
+ global parameter
- bugfix: mmrfc5424addhmac: "key" parameter was not properly processed
+- add new impstats action counters:
+ * suspended
+ * suspended.duration
+ * resumed
---------------------------------------------------------------------------
Version 7.5.7 [v7-devel] 2013-11-25
- queue defaults have changed
diff --git a/action.c b/action.c
index fde3bcfe..cd8c7673 100644
--- a/action.c
+++ b/action.c
@@ -172,6 +172,7 @@ configSettings_t cs_save; /* our saved (scope!) config settings */
* is no better name available.
*/
int iActionNbr = 0;
+int bActionReportSuspension = 1;
/* tables for interfacing with the v6 config system */
static struct cnfparamdescr cnfparamdescr[] = {
@@ -381,6 +382,17 @@ actionConstructFinalize(action_t *pThis, struct nvlst *lst)
CHKiRet(statsobj.AddCounter(pThis->statsobj, UCHAR_CONSTANT("failed"),
ctrType_IntCtr, CTR_FLAG_RESETTABLE, &pThis->ctrFail));
+ STATSCOUNTER_INIT(pThis->ctrSuspend, pThis->mutCtrSuspend);
+ CHKiRet(statsobj.AddCounter(pThis->statsobj, UCHAR_CONSTANT("suspended"),
+ ctrType_IntCtr, CTR_FLAG_RESETTABLE, &pThis->ctrSuspend));
+ STATSCOUNTER_INIT(pThis->ctrSuspendDuration, pThis->mutCtrSuspendDuration);
+ CHKiRet(statsobj.AddCounter(pThis->statsobj, UCHAR_CONSTANT("suspended.duration"),
+ ctrType_IntCtr, 0, &pThis->ctrSuspendDuration));
+
+ STATSCOUNTER_INIT(pThis->ctrResume, pThis->mutCtrResume);
+ CHKiRet(statsobj.AddCounter(pThis->statsobj, UCHAR_CONSTANT("resumed"),
+ ctrType_IntCtr, CTR_FLAG_RESETTABLE, &pThis->ctrResume));
+
CHKiRet(statsobj.ConstructFinalize(pThis->statsobj));
/* create our queue */
@@ -596,7 +608,7 @@ static void actionDisable(action_t *pThis)
}
-/* Suspend action, this involves changing the acton state as well
+/* Suspend action, this involves changing the action state as well
* as setting the next retry time.
* if we have more than 10 retries, we prolong the
* retry interval. If something is really stalled, it will
@@ -604,18 +616,35 @@ static void actionDisable(action_t *pThis)
* CPU time. TODO: maybe a config option for that?
* rgerhards, 2007-08-02
*/
-static inline void actionSuspend(action_t *pThis, wti_t *pWti)
+static inline void
+actionSuspend(action_t * const pThis, wti_t *pWti)
{
time_t ttNow;
+ int suspendDuration;
+ char timebuf[32];
/* note: we can NOT use a cached timestamp, as time may have evolved
* since caching, and this would break logic (and it actually did so!)
*/
datetime.GetTime(&ttNow);
- pThis->ttResumeRtry = ttNow + pThis->iResumeInterval *
- (getActionNbrResRtry(pWti, pThis) / 10 + 1);
+ suspendDuration = pThis->iResumeInterval * (getActionNbrResRtry(pWti, pThis) / 10 + 1);
+ pThis->ttResumeRtry = ttNow + suspendDuration;
actionSetState(pThis, pWti, ACT_STATE_SUSP);
- DBGPRINTF("action suspended, earliest retry=%d\n", (int) pThis->ttResumeRtry);
+ pThis->ctrSuspendDuration += suspendDuration;
+ if(getActionNbrResRtry(pWti, pThis) == 0) {
+ STATSCOUNTER_INC(pThis->ctrSuspend, pThis->mutCtrSuspend);
+ }
+ DBGPRINTF("action '%s' suspended, earliest retry=%lld (now %lld), iNbrResRtry %d, "
+ "duration %d\n",
+ pThis->pszName, (long long) pThis->ttResumeRtry, (long long) ttNow,
+ getActionNbrResRtry(pWti, pThis), suspendDuration);
+ if(bActionReportSuspension) {
+ ctime_r(&pThis->ttResumeRtry, timebuf);
+ timebuf[strlen(timebuf)-1] = '\0'; /* strip LF */
+ errmsg.LogMsg(0, RS_RET_NOT_FOUND, LOG_WARNING,
+ "action '%s' suspended, next retry is %s",
+ pThis->pszName, timebuf);
+ }
}
@@ -646,9 +675,9 @@ actionDoRetry(action_t *pThis, wti_t *pWti)
iRetries = 0;
while((*pWti->pbShutdownImmediate == 0) && getActionState(pWti, pThis) == ACT_STATE_RTRY) {
- DBGPRINTF("actionDoRetry: enter loop, iRetries=%d\n", iRetries);
+ DBGPRINTF("actionDoRetry: %s enter loop, iRetries=%d\n", pThis->pszName, iRetries);
iRet = pThis->pMod->tryResume(pWti->actWrkrInfo[pThis->iActionNbr].actWrkrData);
- DBGPRINTF("actionDoRetry: action->tryResume returned %d\n", iRet);
+ DBGPRINTF("actionDoRetry: %s action->tryResume returned %d\n", pThis->pszName, iRet);
if((getActionResumeInRow(pWti, pThis) > 9) && (getActionResumeInRow(pWti, pThis) % 10 == 0)) {
bTreatOKasSusp = 1;
setActionResumeInRow(pWti, pThis, 0);
@@ -656,16 +685,23 @@ actionDoRetry(action_t *pThis, wti_t *pWti)
bTreatOKasSusp = 0;
}
if((iRet == RS_RET_OK) && (!bTreatOKasSusp)) {
- DBGPRINTF("actionDoRetry: had success RDY again (iRet=%d)\n", iRet);
+ DBGPRINTF("actionDoRetry: %s had success RDY again (iRet=%d)\n",
+ pThis->pszName, iRet);
+ if(bActionReportSuspension) {
+ errmsg.LogMsg(0, RS_RET_OK, LOG_INFO, "action '%s' resumed",
+ pThis->pszName);
+ }
actionSetState(pThis, pWti, ACT_STATE_RDY);
} else if(iRet == RS_RET_SUSPENDED || bTreatOKasSusp) {
/* max retries reached? */
- DBGPRINTF("actionDoRetry: check for max retries, iResumeRetryCount %d, iRetries %d\n",
- pThis->iResumeRetryCount, iRetries);
+ DBGPRINTF("actionDoRetry: %s check for max retries, iResumeRetryCount "
+ "%d, iRetries %d\n",
+ pThis->pszName, pThis->iResumeRetryCount, iRetries);
if((pThis->iResumeRetryCount != -1 && iRetries >= pThis->iResumeRetryCount)) {
actionSuspend(pThis, pWti);
+ if(getActionNbrResRtry(pWti, pThis) < 20)
+ incActionNbrResRtry(pWti, pThis);
} else {
- incActionNbrResRtry(pWti, pThis);
++iRetries;
iSleepPeriod = pThis->iResumeInterval;
srSleep(iSleepPeriod, 0);
diff --git a/action.h b/action.h
index 5b2143b9..7e921c63 100644
--- a/action.h
+++ b/action.h
@@ -28,11 +28,9 @@
#include "syslogd-types.h"
#include "queue.h"
-/* external data - this is to be removed when we change the action
- * object interface (will happen some time..., at latest when the
- * config file format is changed). -- rgerhards, 2008-01-28
- */
+/* external data */
extern int glbliActionResumeRetryCount;
+extern int bActionReportSuspension;
/* the following struct defines the action object data structure
@@ -74,6 +72,9 @@ struct action_s {
statsobj_t *statsobj;
STATSCOUNTER_DEF(ctrProcessed, mutCtrProcessed);
STATSCOUNTER_DEF(ctrFail, mutCtrFail);
+ STATSCOUNTER_DEF(ctrSuspend, mutCtrSuspend);
+ STATSCOUNTER_DEF(ctrSuspendDuration, mutCtrSuspendDuration);
+ STATSCOUNTER_DEF(ctrResume, mutCtrResume);
};
diff --git a/dirty.h b/dirty.h
index 3f8e30d5..f73f5bbd 100644
--- a/dirty.h
+++ b/dirty.h
@@ -5,7 +5,7 @@
* yet a runtime library, because it depends on some functionality
* residing somewhere else.
*
- * Copyright 2007, 2008 Rainer Gerhards and Adiscon GmbH.
+ * Copyright 2007-2013 Rainer Gerhards and Adiscon GmbH.
*
* This file is part of rsyslog.
*
@@ -32,7 +32,7 @@ rsRetVal multiSubmitMsg2(multi_submit_t *pMultiSub); /* friends only! */
rsRetVal submitMsg2(msg_t *pMsg);
rsRetVal __attribute__((deprecated)) submitMsg(msg_t *pMsg);
rsRetVal multiSubmitFlush(multi_submit_t *pMultiSub);
-rsRetVal logmsgInternal(int iErr, int pri, uchar *msg, int flags);
+rsRetVal logmsgInternal(const int iErr, const int pri, const uchar *msg, int flags);
rsRetVal __attribute__((deprecated)) parseAndSubmitMessage(uchar *hname, uchar *hnameIP, uchar *msg, int len, int flags, flowControl_t flowCtlTypeu, prop_t *pInputName, struct syslogTime *stTime, time_t ttGenTime, ruleset_t *pRuleset);
rsRetVal diagGetMainMsgQSize(int *piSize); /* for imdiag */
rsRetVal createMainQueue(qqueue_t **ppQueue, uchar *pszQueueName, struct nvlst *lst);
diff --git a/doc/Makefile.am b/doc/Makefile.am
index f7a9efe0..9a7ed162 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -83,6 +83,7 @@ html_files = \
tls_cert_client.html \
tls_cert_scenario.html \
rainerscript.html \
+ global.html \
lookup_tables.html \
rscript_abnf.html \
rsconf1_actionexeconlywhenpreviousissuspended.html \
diff --git a/doc/global.html b/doc/global.html
new file mode 100644
index 00000000..8b47f6f4
--- /dev/null
+++ b/doc/global.html
@@ -0,0 +1,41 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html><head>
+<title>global() configuration object</title>
+</head>
+
+<body>
+<h1>global() configuration object</h1>
+
+<p>The global configuration object permits to set global parameters.
+Note that each parameter can only be set once and cannot be re-set
+thereafter. If a parameter is set multiple times, the behaviour is
+unpredictable.
+
+<p>The following paramters can be set:
+<ul>
+<li></b>action.reportSuspension</b> - binary, default "on", v7.5.8+c<br>
+If enabled ("on") action will log message under syslog.* when an action
+suspends or resume itself. This usually happens when there are problems
+connecting to backend systems. If disabled ("off"), these messages are
+not generated. These messages can be useful in detecting problems with
+backend systems. Most importantly, frequent suspension and resumption
+points to a problem area.
+<li>workDirectory
+<li>dropMsgsWithMaliciousDNSPtrRecords
+<li>localHostname
+<li>preserveFQDN
+<li>defaultNetstreamDriverCAFile
+<li>defaultNetstreamDriverKeyFile
+<li>defaultNetstreamDriver
+<li>maxMessageSize
+</ul>
+
+<p>[<a href="rsyslog_conf.html">rsyslog.conf overview</a>]
+[<a href="rainerscript.html">RainerScript reference</a>] [<a href="http://www.rsyslog.com/">rsyslog site</a>]</p>
+<p><font size="2">This documentation is part of the
+<a href="http://www.rsyslog.com/">rsyslog</a> project.<br>
+Copyright &copy; 2013 by <a href="http://www.gerhards.net/rainer">Rainer Gerhards</a> and
+<a href="http://www.adiscon.com/">Adiscon</a>.
+Released under ASL 2.0 or higher.</font></p>
+</body>
+</html>
diff --git a/doc/rainerscript.html b/doc/rainerscript.html
index 0a780ac4..217ef28a 100644
--- a/doc/rainerscript.html
+++ b/doc/rainerscript.html
@@ -67,6 +67,9 @@ $MainMsgQ... statements are ignored.
<p>Example:</p>
<textarea rows="2" cols="60">main_queue(queue.size="100000" queue.type="LinkedList")
</textarea>
+<h3>global()</h3>
+<p>This is used to set global configuration parameters. For details, please
+see the <a href="rsyslog_global">rsyslog global configuration object</a>.
<h2>Expressions</h2>
The language supports arbitrary complex expressions. All usual
operators are supported. The precedence of operations is as follows
diff --git a/runtime/errmsg.c b/runtime/errmsg.c
index dcb5b185..b3941431 100644
--- a/runtime/errmsg.c
+++ b/runtime/errmsg.c
@@ -7,7 +7,7 @@
* to take further case, as the code now boils to be either my own or, a few lines,
* of the original BSD-licenses sysklogd code. rgerhards, 2012-01-16
*
- * Copyright 2008-2012 Adiscon GmbH.
+ * Copyright 2008-2013 Adiscon GmbH.
*
* This file is part of the rsyslog runtime library.
*
@@ -56,51 +56,90 @@ DEFobjStaticHelpers
* maps to a specific error event).
* rgerhards, 2008-06-27
*/
-static void __attribute__((format(printf, 3, 4)))
-LogError(int iErrno, int iErrCode, char *fmt, ... )
+static void
+doLogMsg(const int iErrno, const int iErrCode, const int severity, const char *msg)
{
- va_list ap;
- char buf[1024];
- char msg[1024];
+ char buf[2048];
char errStr[1024];
- size_t lenBuf;
-
- BEGINfunc
- assert(fmt != NULL);
- /* 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... */
-
- dbgprintf("Called LogError, msg: %s\n", buf);
+ dbgprintf("Called LogMsg, msg: %s\n", msg);
if(iErrno != 0) {
rs_strerror_r(iErrno, errStr, sizeof(errStr));
if(iErrCode == NO_ERRCODE || iErrCode == RS_RET_ERR) {
- snprintf(msg, sizeof(msg), "%s: %s", buf, errStr);
+ snprintf(buf, sizeof(buf), "%s: %s", msg, errStr);
} else {
- snprintf(msg, sizeof(msg), "%s: %s [try http://www.rsyslog.com/e/%d ]", buf, errStr, iErrCode * -1);
+ snprintf(buf, sizeof(buf), "%s: %s [try http://www.rsyslog.com/e/%d ]", msg, errStr, iErrCode * -1);
}
} else {
if(iErrCode == NO_ERRCODE || iErrCode == RS_RET_ERR) {
- snprintf(msg, sizeof(msg), "%s", buf);
+ snprintf(buf, sizeof(buf), "%s", msg);
} else {
- snprintf(msg, sizeof(msg), "%s [try http://www.rsyslog.com/e/%d ]", buf, iErrCode * -1);
+ snprintf(buf, sizeof(buf), "%s [try http://www.rsyslog.com/e/%d ]", msg, iErrCode * -1);
}
}
- msg[sizeof(msg)/sizeof(char) - 1] = '\0'; /* just to be on the safe side... */
+ buf[sizeof(buf)/sizeof(char) - 1] = '\0'; /* just to be on the safe side... */
errno = 0;
- glblErrLogger(iErrCode, (uchar*)msg);
+ glblErrLogger(severity, iErrCode, (uchar*)buf);
+}
+
+/* We now receive three parameters: one is the internal error code
+ * which will also become the error message number, the second is
+ * errno - if it is non-zero, the corresponding error message is included
+ * in the text and finally the message text itself. Note that it is not
+ * 100% clean to use the internal errcode, as it may be reached from
+ * multiple actual error causes. However, it is much better than having
+ * no error code at all (and in most cases, a single internal error code
+ * maps to a specific error event).
+ * rgerhards, 2008-06-27
+ */
+static void __attribute__((format(printf, 3, 4)))
+LogError(const int iErrno, const int iErrCode, const char *fmt, ... )
+{
+ va_list ap;
+ char buf[2048];
+ size_t lenBuf;
+
+ 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);
+ buf[sizeof(buf)/sizeof(char) - 1] = '\0'; /* just to be on the safe side... */
+
+ doLogMsg(iErrno, iErrCode, LOG_ERR, buf);
+}
- ENDfunc
+/* We now receive three parameters: one is the internal error code
+ * which will also become the error message number, the second is
+ * errno - if it is non-zero, the corresponding error message is included
+ * in the text and finally the message text itself. Note that it is not
+ * 100% clean to use the internal errcode, as it may be reached from
+ * multiple actual error causes. However, it is much better than having
+ * no error code at all (and in most cases, a single internal error code
+ * maps to a specific error event).
+ * rgerhards, 2008-06-27
+ */
+static void __attribute__((format(printf, 4, 5)))
+LogMsg(const int iErrno, const int iErrCode, const int severity, const char *fmt, ... )
+{
+ va_list ap;
+ char buf[2048];
+ size_t lenBuf;
+
+ 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);
+ buf[sizeof(buf)/sizeof(char) - 1] = '\0'; /* just to be on the safe side... */
+
+ doLogMsg(iErrno, iErrCode, severity, buf);
}
@@ -119,6 +158,7 @@ CODESTARTobjQueryInterface(errmsg)
* of course, also affects the "if" above).
*/
pIf->LogError = LogError;
+ pIf->LogMsg = LogMsg;
finalize_it:
ENDobjQueryInterface(errmsg)
diff --git a/runtime/errmsg.h b/runtime/errmsg.h
index dfa70c00..b1b4741f 100644
--- a/runtime/errmsg.h
+++ b/runtime/errmsg.h
@@ -1,6 +1,6 @@
/* The errmsg object. It is used to emit error message inside rsyslog.
*
- * Copyright 2008-2012 Rainer Gerhards and Adiscon GmbH.
+ * Copyright 2008-2013 Rainer Gerhards and Adiscon GmbH.
*
* This file is part of the rsyslog runtime library.
*
@@ -23,7 +23,6 @@
#include "errmsg.h"
-/* TODO: define error codes */
#define NO_ERRCODE -1
/* the errmsg object */
@@ -34,9 +33,11 @@ typedef struct errmsg_s {
/* interfaces */
BEGINinterface(errmsg) /* name must also be changed in ENDinterface macro! */
- void __attribute__((format(printf, 3, 4))) (*LogError)(int iErrno, int iErrCode, char *pszErrFmt, ... );
+ void __attribute__((format(printf, 3, 4))) (*LogError)(const int iErrno, const int iErrCode, const char *pszErrFmt, ... );
+ /* v2, 2013-11-29 */
+ void __attribute__((format(printf, 4, 5))) (*LogMsg)(const int iErrno, const int iErrCode, const int severity, const char *pszErrFmt, ... );
ENDinterface(errmsg)
-#define errmsgCURR_IF_VERSION 1 /* increment whenever you change the interface structure! */
+#define errmsgCURR_IF_VERSION 2 /* increment whenever you change the interface structure! */
/* prototypes */
diff --git a/runtime/glbl.c b/runtime/glbl.c
index e1d4e92d..3983a449 100644
--- a/runtime/glbl.c
+++ b/runtime/glbl.c
@@ -43,6 +43,7 @@
#include "prop.h"
#include "atomic.h"
#include "errmsg.h"
+#include "action.h"
#include "rainerscript.h"
#include "net.h"
@@ -105,6 +106,7 @@ static struct cnfparamdescr cnfparamdescr[] = {
{ "defaultnetstreamdriverkeyfile", eCmdHdlrString, 0 },
{ "defaultnetstreamdriver", eCmdHdlrString, 0 },
{ "maxmessagesize", eCmdHdlrSize, 0 },
+ { "action.reportsuspension", eCmdHdlrBinary, 0 }
};
static struct cnfparamblk paramblk =
{ CNFPARAMBLK_VERSION,
@@ -693,6 +695,8 @@ glblDoneLoadCnf(void)
} else if(!strcmp(paramblk.descr[i].name,
"dropmsgswithmaliciousdnsptrrecords")) {
bDropMalPTRMsgs = (int) cnfparamvals[i].val.d.n;
+ } else if(!strcmp(paramblk.descr[i].name, "action.reportsuspension")) {
+ bActionReportSuspension = (int) cnfparamvals[i].val.d.n;
} else if(!strcmp(paramblk.descr[i].name, "maxmessagesize")) {
iMaxLine = (int) cnfparamvals[i].val.d.n;
} else {
diff --git a/runtime/rsyslog.c b/runtime/rsyslog.c
index 53c7855a..a3d4057e 100644
--- a/runtime/rsyslog.c
+++ b/runtime/rsyslog.c
@@ -35,7 +35,7 @@
*
* Module begun 2008-04-16 by Rainer Gerhards
*
- * Copyright 2008 Rainer Gerhards and Adiscon GmbH.
+ * Copyright 2008-2013 Rainer Gerhards and Adiscon GmbH.
*
* This file is part of the rsyslog runtime library.
*
@@ -86,11 +86,11 @@ int default_thr_sched_policy;
#endif
/* forward definitions */
-static rsRetVal dfltErrLogger(int, uchar *errMsg);
+static void dfltErrLogger(const int, const int, const uchar *errMsg);
/* globally visible static data - see comment in rsyslog.h for details */
uchar *glblModPath; /* module load path */
-rsRetVal (*glblErrLogger)(int, uchar*) = dfltErrLogger; /* the error logger to use by the errmsg module */
+void (*glblErrLogger)(const int, const int, const uchar*) = dfltErrLogger; /* the error logger to use by the errmsg module */
/* static data */
static int iRefCount = 0; /* our refcount - it MUST exist only once inside a process (not thread)
@@ -102,24 +102,21 @@ static int iRefCount = 0; /* our refcount - it MUST exist only once inside a pro
* default so that we can log errors during the intial phase, most importantly
* during initialization. -- rgerhards. 2008-04-17
*/
-static rsRetVal dfltErrLogger(int iErr, uchar *errMsg)
+static void
+dfltErrLogger(const int severity, const int iErr, const uchar *errMsg)
{
- DEFiRet;
- fprintf(stderr, "rsyslog runtime error(%d): %s\n", iErr, errMsg);
- RETiRet;
+ fprintf(stderr, "rsyslog runtime error(%d,%d): %s\n", severity, iErr, errMsg);
}
/* set the error log function
* rgerhards, 2008-04-18
*/
-rsRetVal
-rsrtSetErrLogger(rsRetVal (*errLogger)(int, uchar*))
+void
+rsrtSetErrLogger(void (*errLogger)(const int, const int, const uchar*))
{
- DEFiRet;
assert(errLogger != NULL);
glblErrLogger = errLogger;
- RETiRet;
}
diff --git a/runtime/rsyslog.h b/runtime/rsyslog.h
index e0331da7..dfbfc448 100644
--- a/runtime/rsyslog.h
+++ b/runtime/rsyslog.h
@@ -506,13 +506,13 @@ void dbgprintf(char *, ...) __attribute__((format(printf, 1, 2)));
* add them. -- rgerhards, 2008-04-17
*/
extern uchar *glblModPath; /* module load path */
-extern rsRetVal (*glblErrLogger)(int, uchar*);
+extern void (*glblErrLogger)(const int, const int, const uchar*);
/* some runtime prototypes */
rsRetVal rsrtInit(char **ppErrObj, obj_if_t *pObjIF);
rsRetVal rsrtExit(void);
int rsrtIsInit(void);
-rsRetVal rsrtSetErrLogger(rsRetVal (*errLogger)(int, uchar*));
+void rsrtSetErrLogger(void (*errLogger)(const int, const int, const uchar*));
/* this define below is (later) intended to be used to implement empty
* structs. TODO: check if compilers supports this and, if not, define
diff --git a/tools/syslogd.c b/tools/syslogd.c
index ab905d49..f9cc4182 100644
--- a/tools/syslogd.c
+++ b/tools/syslogd.c
@@ -21,7 +21,7 @@
* For further information, please see http://www.rsyslog.com
*
* rsyslog - An Enhanced syslogd Replacement.
- * Copyright 2003-2012 Rainer Gerhards and Adiscon GmbH.
+ * Copyright 2003-2013 Rainer Gerhards and Adiscon GmbH.
*
* This file is part of rsyslog.
*
@@ -417,12 +417,10 @@ finalize_it:
* function is also passed to the runtime library as the generic error
* message handler. -- rgerhards, 2008-04-17
*/
-rsRetVal
-submitErrMsg(int iErr, uchar *msg)
+void
+submitErrMsg(const int severity, const int iErr, const uchar *msg)
{
- DEFiRet;
- iRet = logmsgInternal(iErr, LOG_SYSLOG|LOG_ERR, msg, 0);
- RETiRet;
+ logmsgInternal(iErr, LOG_SYSLOG|(severity & 0x07), msg, 0);
}
@@ -436,7 +434,7 @@ submitMsgWithDfltRatelimiter(msg_t *pMsg)
* to log a message orginating from the syslogd itself.
*/
rsRetVal
-logmsgInternal(int iErr, int pri, uchar *msg, int flags)
+logmsgInternal(const int iErr, const int pri, const uchar *msg, int flags)
{
uchar pszTag[33];
msg_t *pMsg;
@@ -484,7 +482,6 @@ logmsgInternal(int iErr, int pri, uchar *msg, int flags)
* message to the queue engine.
*/
ratelimitAddMsg(internalMsg_ratelimiter, NULL, pMsg);
- //submitMsgWithDfltRatelimiter(pMsg);
}
finalize_it:
RETiRet;
@@ -1365,7 +1362,7 @@ InitGlobalClasses(void)
/* Intialize the runtime system */
pErrObj = "rsyslog runtime"; /* set in case the runtime errors before setting an object */
CHKiRet(rsrtInit(&pErrObj, &obj));
- CHKiRet(rsrtSetErrLogger(submitErrMsg)); /* set out error handler */
+ rsrtSetErrLogger(submitErrMsg);
/* Now tell the system which classes we need ourselfs */
pErrObj = "glbl";