diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2008-06-27 12:52:45 +0200 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2008-06-27 12:52:45 +0200 |
commit | 3f6c73a8b7ff2c6d9c931876d823f2b4ef6bbea2 (patch) | |
tree | a147c4dbda59de0675b0c2a5e80a2b6f97569691 /plugins | |
parent | d4518082362afebef9400bcbf46e38228de83bf1 (diff) | |
download | rsyslog-3f6c73a8b7ff2c6d9c931876d823f2b4ef6bbea2.tar.gz rsyslog-3f6c73a8b7ff2c6d9c931876d823f2b4ef6bbea2.tar.xz rsyslog-3f6c73a8b7ff2c6d9c931876d823f2b4ef6bbea2.zip |
added (internal) error codes to error messages
Also added redirector to web description of error codes
closes bug http://bugzilla.adiscon.com/show_bug.cgi?id=20
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/imfile/imfile.c | 10 | ||||
-rw-r--r-- | plugins/imgssapi/imgssapi.c | 14 | ||||
-rw-r--r-- | plugins/immark/immark.c | 3 | ||||
-rw-r--r-- | plugins/imtcp/imtcp.c | 2 | ||||
-rw-r--r-- | plugins/imudp/imudp.c | 4 | ||||
-rw-r--r-- | plugins/imuxsock/imuxsock.c | 6 | ||||
-rw-r--r-- | plugins/omgssapi/omgssapi.c | 16 | ||||
-rw-r--r-- | plugins/ommysql/ommysql.c | 8 | ||||
-rw-r--r-- | plugins/ompgsql/ompgsql.c | 6 | ||||
-rw-r--r-- | plugins/omrelp/omrelp.c | 12 |
10 files changed, 41 insertions, 40 deletions
diff --git a/plugins/imfile/imfile.c b/plugins/imfile/imfile.c index d4a332eb..dbdf6b94 100644 --- a/plugins/imfile/imfile.c +++ b/plugins/imfile/imfile.c @@ -318,7 +318,7 @@ ENDrunInput BEGINwillRun CODESTARTwillRun if(iFilPtr == 0) { - errmsg.LogError(NO_ERRCODE, "No files configured to be monitored"); + errmsg.LogError(0, RS_RET_NO_RUN, "No files configured to be monitored"); ABORT_FINALIZE(RS_RET_NO_RUN); } @@ -447,21 +447,21 @@ static rsRetVal addMonitor(void __attribute__((unused)) *pVal, uchar *pNewVal) pThis = &files[iFilPtr]; /* TODO: check for strdup() NULL return */ if(pszFileName == NULL) { - errmsg.LogError(NO_ERRCODE, "imfile error: no file name given, file monitor can not be created"); + errmsg.LogError(0, RS_RET_CONFIG_ERROR, "imfile error: no file name given, file monitor can not be created"); ABORT_FINALIZE(RS_RET_CONFIG_ERROR); } else { pThis->pszFileName = (uchar*) strdup((char*) pszFileName); } if(pszFileTag == NULL) { - errmsg.LogError(NO_ERRCODE, "imfile error: no tag value given , file monitor can not be created"); + errmsg.LogError(0, RS_RET_CONFIG_ERROR, "imfile error: no tag value given , file monitor can not be created"); ABORT_FINALIZE(RS_RET_CONFIG_ERROR); } else { pThis->pszTag = (uchar*) strdup((char*) pszFileTag); } if(pszStateFile == NULL) { - errmsg.LogError(NO_ERRCODE, "imfile error: not state file name given, file monitor can not be created"); + errmsg.LogError(0, RS_RET_CONFIG_ERROR, "imfile error: not state file name given, file monitor can not be created"); ABORT_FINALIZE(RS_RET_CONFIG_ERROR); } else { pThis->pszStateFile = (uchar*) strdup((char*) pszStateFile); @@ -470,7 +470,7 @@ static rsRetVal addMonitor(void __attribute__((unused)) *pVal, uchar *pNewVal) pThis->iSeverity = iSeverity; pThis->iFacility = iFacility; } else { - errmsg.LogError(NO_ERRCODE, "Too many file monitors configured - ignoring this one"); + errmsg.LogError(0, RS_RET_OUT_OF_DESRIPTORS, "Too many file monitors configured - ignoring this one"); ABORT_FINALIZE(RS_RET_OUT_OF_DESRIPTORS); } diff --git a/plugins/imgssapi/imgssapi.c b/plugins/imgssapi/imgssapi.c index 24317b51..766cb519 100644 --- a/plugins/imgssapi/imgssapi.c +++ b/plugins/imgssapi/imgssapi.c @@ -258,7 +258,7 @@ doOpenLstnSocks(tcpsrv_t *pSrv) if(pGSrv->allowedMethods) { if(pGSrv->allowedMethods & ALLOWEDMETHOD_GSS) { if(TCPSessGSSInit()) { - errmsg.LogError(NO_ERRCODE, "GSS-API initialization failed\n"); + errmsg.LogError(0, NO_ERRCODE, "GSS-API initialization failed\n"); pGSrv->allowedMethods &= ~(ALLOWEDMETHOD_GSS); } } @@ -413,7 +413,7 @@ OnSessAcceptGSS(tcpsrv_t *pThis, tcps_sess_t *pSess) ret = select(fdSess + 1, &fds, NULL, NULL, &tv); } while (ret < 0 && errno == EINTR); if (ret < 0) { - errmsg.LogError(NO_ERRCODE, "TCP session %p will be closed, error ignored\n", pSess); + errmsg.LogError(0, RS_RET_ERR, "TCP session %p will be closed, error ignored\n", pSess); ABORT_FINALIZE(RS_RET_ERR); // TODO: define good error codes } else if (ret == 0) { dbgprintf("GSS-API Reverting to plain TCP\n"); @@ -428,7 +428,7 @@ OnSessAcceptGSS(tcpsrv_t *pThis, tcps_sess_t *pSess) if (ret == 0) dbgprintf("GSS-API Connection closed by peer\n"); else - errmsg.LogError(NO_ERRCODE, "TCP(GSS) session %p will be closed, error ignored\n", pSess); + errmsg.LogError(0, RS_RET_ERR, "TCP(GSS) session %p will be closed, error ignored\n", pSess); ABORT_FINALIZE(RS_RET_ERR); // TODO: define good error codes } @@ -448,7 +448,7 @@ OnSessAcceptGSS(tcpsrv_t *pThis, tcps_sess_t *pSess) if (ret == 0) dbgprintf("GSS-API Connection closed by peer\n"); else - errmsg.LogError(NO_ERRCODE, "TCP session %p will be closed, error ignored\n", pSess); + errmsg.LogError(0, NO_ERRCODE, "TCP session %p will be closed, error ignored\n", pSess); ABORT_FINALIZE(RS_RET_ERR); // TODO: define good error codes } } @@ -470,7 +470,7 @@ OnSessAcceptGSS(tcpsrv_t *pThis, tcps_sess_t *pSess) sess_flags = &pGSess->gss_flags; do { if (gssutil.recv_token(fdSess, &recv_tok) <= 0) { - errmsg.LogError(NO_ERRCODE, "TCP session %p will be closed, error ignored\n", pSess); + errmsg.LogError(0, NO_ERRCODE, "TCP session %p will be closed, error ignored\n", pSess); ABORT_FINALIZE(RS_RET_ERR); // TODO: define good error codes } maj_stat = gss_accept_sec_context(&acc_sec_min_stat, context, gss_server_creds, @@ -489,7 +489,7 @@ OnSessAcceptGSS(tcpsrv_t *pThis, tcps_sess_t *pSess) dbgprintf("GSS-API Reverting to plain TCP\n"); dbgprintf("tcp session socket with new data: #%d\n", fdSess); if(tcps_sess.DataRcvd(pSess, buf, ret) != RS_RET_OK) { - errmsg.LogError(NO_ERRCODE, "Tearing down TCP Session %p - see " + errmsg.LogError(0, NO_ERRCODE, "Tearing down TCP Session %p - see " "previous messages for reason(s)\n", pSess); ABORT_FINALIZE(RS_RET_ERR); // TODO: define good error codes } @@ -502,7 +502,7 @@ OnSessAcceptGSS(tcpsrv_t *pThis, tcps_sess_t *pSess) if (send_tok.length != 0) { if(gssutil.send_token(fdSess, &send_tok) < 0) { gss_release_buffer(&min_stat, &send_tok); - errmsg.LogError(NO_ERRCODE, "TCP session %p will be closed, error ignored\n", pSess); + errmsg.LogError(0, NO_ERRCODE, "TCP session %p will be closed, error ignored\n", pSess); if (*context != GSS_C_NO_CONTEXT) gss_delete_sec_context(&min_stat, context, GSS_C_NO_BUFFER); ABORT_FINALIZE(RS_RET_ERR); // TODO: define good error codes diff --git a/plugins/immark/immark.c b/plugins/immark/immark.c index ebdcabe9..0baff1de 100644 --- a/plugins/immark/immark.c +++ b/plugins/immark/immark.c @@ -40,6 +40,7 @@ #include "dirty.h" #include "cfsysline.h" #include "module-template.h" +#include "errmsg.h" MODULE_TYPE_INPUT @@ -75,7 +76,7 @@ CODESTARTrunInput * rgerhards, 2007-12-17 */ CHKiRet(thrdSleep(pThrd, iMarkMessagePeriod, 0)); /* seconds, micro seconds */ - logmsgInternal(LOG_INFO, (uchar*)"-- MARK --", ADDDATE|MARK); + logmsgInternal(NO_ERRCODE, LOG_INFO, (uchar*)"-- MARK --", ADDDATE|MARK); } finalize_it: return iRet; diff --git a/plugins/imtcp/imtcp.c b/plugins/imtcp/imtcp.c index 49d48633..f01a9f0f 100644 --- a/plugins/imtcp/imtcp.c +++ b/plugins/imtcp/imtcp.c @@ -180,7 +180,7 @@ static rsRetVal addTCPListener(void __attribute__((unused)) *pVal, uchar *pNewVa finalize_it: if(iRet != RS_RET_OK) { - errmsg.LogError(NO_ERRCODE, "error %d trying to add listener", iRet); + errmsg.LogError(0, NO_ERRCODE, "error %d trying to add listener", iRet); if(pOurTcpsrv != NULL) tcpsrv.Destruct(&pOurTcpsrv); } diff --git a/plugins/imudp/imudp.c b/plugins/imudp/imudp.c index 54dc6836..6d3a075f 100644 --- a/plugins/imudp/imudp.c +++ b/plugins/imudp/imudp.c @@ -199,7 +199,7 @@ CODESTARTrunInput } else { dbgprintf("%s is not an allowed sender\n", (char*)fromHostFQDN); if(glbl.GetOption_DisallowWarning) { - errmsg.LogError(NO_ERRCODE, "UDP message from disallowed sender %s discarded", + errmsg.LogError(0, NO_ERRCODE, "UDP message from disallowed sender %s discarded", (char*)fromHost); } } @@ -208,7 +208,7 @@ CODESTARTrunInput char errStr[1024]; rs_strerror_r(errno, errStr, sizeof(errStr)); dbgprintf("INET socket error: %d = %s.\n", errno, errStr); - errmsg.LogError(NO_ERRCODE, "recvfrom inet"); + errmsg.LogError(errno, NO_ERRCODE, "recvfrom inet"); /* should be harmless */ sleep(1); } diff --git a/plugins/imuxsock/imuxsock.c b/plugins/imuxsock/imuxsock.c index 82fd118e..5781589f 100644 --- a/plugins/imuxsock/imuxsock.c +++ b/plugins/imuxsock/imuxsock.c @@ -114,7 +114,7 @@ static rsRetVal addLstnSocketName(void __attribute__((unused)) *pVal, uchar *pNe funixn[nfunix++] = pNewVal; } else { - errmsg.LogError(NO_ERRCODE, "Out of unix socket name descriptors, ignoring %s\n", + errmsg.LogError(0, NO_ERRCODE, "Out of unix socket name descriptors, ignoring %s\n", pNewVal); } @@ -159,7 +159,7 @@ static int create_unix_socket(const char *path) SUN_LEN(&sunx)) < 0 || chmod(path, 0666) < 0) { snprintf(line, sizeof(line), "cannot create %s", path); - errmsg.LogError(NO_ERRCODE, "%s", line); + errmsg.LogError(errno, NO_ERRCODE, "%s", line); dbgprintf("cannot create %s (%d).\n", path, errno); close(fd); return -1; @@ -187,7 +187,7 @@ static rsRetVal readSocket(int fd, int bParseHost, int flags) char errStr[1024]; rs_strerror_r(errno, errStr, sizeof(errStr)); dbgprintf("UNIX socket error: %d = %s.\n", errno, errStr); - errmsg.LogError(NO_ERRCODE, "recvfrom UNIX"); + errmsg.LogError(errno, NO_ERRCODE, "recvfrom UNIX"); } RETiRet; diff --git a/plugins/omgssapi/omgssapi.c b/plugins/omgssapi/omgssapi.c index e15c24e1..6573c46a 100644 --- a/plugins/omgssapi/omgssapi.c +++ b/plugins/omgssapi/omgssapi.c @@ -268,7 +268,7 @@ finalize_it: RETiRet; fail: - errmsg.LogError(NO_ERRCODE, "GSS-API Context initialization failed\n"); + errmsg.LogError(0, RS_RET_GSS_SENDINIT_ERROR, "GSS-API Context initialization failed\n"); gss_release_name(&min_stat, &target_name); gss_release_buffer(&min_stat, &out_tok); if (*context != GSS_C_NO_CONTEXT) { @@ -501,12 +501,12 @@ CODE_STD_STRING_REQUESTparseSelectorAct(1) ++p; /* eat */ pData->compressionLevel = iLevel; } else { - errmsg.LogError(NO_ERRCODE, "Invalid compression level '%c' specified in " + errmsg.LogError(0, NO_ERRCODE, "Invalid compression level '%c' specified in " "forwardig action - NOT turning on compression.", *p); } # else - errmsg.LogError(NO_ERRCODE, "Compression requested, but rsyslogd is not compiled " + errmsg.LogError(0, NO_ERRCODE, "Compression requested, but rsyslogd is not compiled " "with compression support - request ignored."); # endif /* #ifdef USE_NETZIP */ } else if(*p == 'o') { /* octet-couting based TCP framing? */ @@ -514,7 +514,7 @@ CODE_STD_STRING_REQUESTparseSelectorAct(1) /* no further options settable */ tcp_framing = TCP_FRAMING_OCTET_COUNTING; } else { /* invalid option! Just skip it... */ - errmsg.LogError(NO_ERRCODE, "Invalid option %c in forwarding action - ignoring.", *p); + errmsg.LogError(0, NO_ERRCODE, "Invalid option %c in forwarding action - ignoring.", *p); ++p; /* eat invalid option */ } /* the option processing is done. We now do a generic skip @@ -530,7 +530,7 @@ CODE_STD_STRING_REQUESTparseSelectorAct(1) /* we probably have end of string - leave it for the rest * of the code to handle it (but warn the user) */ - errmsg.LogError(NO_ERRCODE, "Option block not terminated in gssapi forward action."); + errmsg.LogError(0, NO_ERRCODE, "Option block not terminated in gssapi forward action."); } /* extract the host first (we do a trick - we replace the ';' or ':' with a '\0') * now skip to port and then template name. rgerhards 2005-07-06 @@ -548,7 +548,7 @@ CODE_STD_STRING_REQUESTparseSelectorAct(1) /* SKIP AND COUNT */; pData->port = malloc(i + 1); if(pData->port == NULL) { - errmsg.LogError(NO_ERRCODE, "Could not get memory to store syslog forwarding port, " + errmsg.LogError(0, NO_ERRCODE, "Could not get memory to store syslog forwarding port, " "using default port, results may not be what you intend\n"); /* we leave f_forw.port set to NULL, this is then handled by * getFwdSyslogPt(). @@ -566,7 +566,7 @@ CODE_STD_STRING_REQUESTparseSelectorAct(1) if(bErr == 0) { /* only 1 error msg! */ bErr = 1; errno = 0; - errmsg.LogError(NO_ERRCODE, "invalid selector line (port), probably not doing " + errmsg.LogError(0, NO_ERRCODE, "invalid selector line (port), probably not doing " "what was intended"); } } @@ -646,7 +646,7 @@ static rsRetVal setGSSMode(void __attribute__((unused)) *pVal, uchar *mode) gss_mode = GSSMODE_ENC; dbgprintf("GSS-API gssmode set to GSSMODE_ENC\n"); } else { - errmsg.LogError(NO_ERRCODE, "unknown gssmode parameter: %s", (char *) mode); + errmsg.LogError(0, RS_RET_INVALID_PARAMS, "unknown gssmode parameter: %s", (char *) mode); iRet = RS_RET_INVALID_PARAMS; } free(mode); diff --git a/plugins/ommysql/ommysql.c b/plugins/ommysql/ommysql.c index 472cb10d..e69ab40b 100644 --- a/plugins/ommysql/ommysql.c +++ b/plugins/ommysql/ommysql.c @@ -115,7 +115,7 @@ static void reportDBError(instanceData *pData, int bSilent) /* output log message */ errno = 0; if(pData->f_hmysql == NULL) { - errmsg.LogError(NO_ERRCODE, "unknown DB error occured - could not obtain MySQL handle"); + errmsg.LogError(0, NO_ERRCODE, "unknown DB error occured - could not obtain MySQL handle"); } else { /* we can ask mysql for the error description... */ uMySQLErrno = mysql_errno(pData->f_hmysql); snprintf(errMsg, sizeof(errMsg)/sizeof(char), "db error (%d): %s\n", uMySQLErrno, @@ -124,7 +124,7 @@ static void reportDBError(instanceData *pData, int bSilent) dbgprintf("mysql, DBError(silent): %s\n", errMsg); else { pData->uLastMySQLErrno = uMySQLErrno; - errmsg.LogError(NO_ERRCODE, "%s", errMsg); + errmsg.LogError(0, NO_ERRCODE, "%s", errMsg); } } @@ -145,7 +145,7 @@ static rsRetVal initMySQL(instanceData *pData, int bSilent) pData->f_hmysql = mysql_init(NULL); if(pData->f_hmysql == NULL) { - errmsg.LogError(NO_ERRCODE, "can not initialize MySQL handle"); + errmsg.LogError(0, RS_RET_SUSPENDED, "can not initialize MySQL handle"); iRet = RS_RET_SUSPENDED; } else { /* we could get the handle, now on with work... */ /* Connect to database */ @@ -270,7 +270,7 @@ CODE_STD_STRING_REQUESTparseSelectorAct(1) * Retries make no sense. */ if (iMySQLPropErr) { - errmsg.LogError(NO_ERRCODE, "Trouble with MySQL connection properties. -MySQL logging disabled"); + errmsg.LogError(0, RS_RET_INVALID_PARAMS, "Trouble with MySQL connection properties. -MySQL logging disabled"); ABORT_FINALIZE(RS_RET_INVALID_PARAMS); } else { pData->f_hmysql = NULL; /* initialize, but connect only on first message (important for queued mode!) */ diff --git a/plugins/ompgsql/ompgsql.c b/plugins/ompgsql/ompgsql.c index 77fd6a07..f8685672 100644 --- a/plugins/ompgsql/ompgsql.c +++ b/plugins/ompgsql/ompgsql.c @@ -113,7 +113,7 @@ static void reportDBError(instanceData *pData, int bSilent) /* output log message */ errno = 0; if(pData->f_hpgsql == NULL) { - errmsg.LogError(NO_ERRCODE, "unknown DB error occured - could not obtain PgSQL handle"); + errmsg.LogError(0, NO_ERRCODE, "unknown DB error occured - could not obtain PgSQL handle"); } else { /* we can ask pgsql for the error description... */ ePgSQLStatus = PQstatus(pData->f_hpgsql); snprintf(errMsg, sizeof(errMsg)/sizeof(char), "db error (%d): %s\n", ePgSQLStatus, @@ -122,7 +122,7 @@ static void reportDBError(instanceData *pData, int bSilent) dbgprintf("pgsql, DBError(silent): %s\n", errMsg); else { pData->eLastPgSQLStatus = ePgSQLStatus; - errmsg.LogError(NO_ERRCODE, "%s", errMsg); + errmsg.LogError(0, NO_ERRCODE, "%s", errMsg); } } @@ -264,7 +264,7 @@ CODE_STD_STRING_REQUESTparseSelectorAct(1) * Retries make no sense. */ if (iPgSQLPropErr) { - errmsg.LogError(NO_ERRCODE, "Trouble with PgSQL connection properties. -PgSQL logging disabled"); + errmsg.LogError(0, RS_RET_INVALID_PARAMS, "Trouble with PgSQL connection properties. -PgSQL logging disabled"); ABORT_FINALIZE(RS_RET_INVALID_PARAMS); } else { CHKiRet(initPgSQL(pData, 0)); diff --git a/plugins/omrelp/omrelp.c b/plugins/omrelp/omrelp.c index 2977053a..41c72879 100644 --- a/plugins/omrelp/omrelp.c +++ b/plugins/omrelp/omrelp.c @@ -220,16 +220,16 @@ CODE_STD_STRING_REQUESTparseSelectorAct(1) ++p; /* eat */ pData->compressionLevel = iLevel; } else { - errmsg.LogError(NO_ERRCODE, "Invalid compression level '%c' specified in " + errmsg.LogError(0, NO_ERRCODE, "Invalid compression level '%c' specified in " "forwardig action - NOT turning on compression.", *p); } # else - errmsg.LogError(NO_ERRCODE, "Compression requested, but rsyslogd is not compiled " + errmsg.LogError(0, NO_ERRCODE, "Compression requested, but rsyslogd is not compiled " "with compression support - request ignored."); # endif /* #ifdef USE_NETZIP */ } else { /* invalid option! Just skip it... */ - errmsg.LogError(NO_ERRCODE, "Invalid option %c in forwarding action - ignoring.", *p); + errmsg.LogError(0, NO_ERRCODE, "Invalid option %c in forwarding action - ignoring.", *p); ++p; /* eat invalid option */ } /* the option processing is done. We now do a generic skip @@ -245,7 +245,7 @@ CODE_STD_STRING_REQUESTparseSelectorAct(1) /* we probably have end of string - leave it for the rest * of the code to handle it (but warn the user) */ - errmsg.LogError(NO_ERRCODE, "Option block not terminated in forwarding action."); + errmsg.LogError(0, NO_ERRCODE, "Option block not terminated in forwarding action."); } /* extract the host first (we do a trick - we replace the ';' or ':' with a '\0') * now skip to port and then template name. rgerhards 2005-07-06 @@ -263,7 +263,7 @@ CODE_STD_STRING_REQUESTparseSelectorAct(1) /* SKIP AND COUNT */; pData->port = malloc(i + 1); if(pData->port == NULL) { - errmsg.LogError(NO_ERRCODE, "Could not get memory to store relp port, " + errmsg.LogError(0, NO_ERRCODE, "Could not get memory to store relp port, " "using default port, results may not be what you intend\n"); /* we leave f_forw.port set to NULL, this is then handled by getRelpPt() */ } else { @@ -279,7 +279,7 @@ CODE_STD_STRING_REQUESTparseSelectorAct(1) if(bErr == 0) { /* only 1 error msg! */ bErr = 1; errno = 0; - errmsg.LogError(NO_ERRCODE, "invalid selector line (port), probably not doing " + errmsg.LogError(0, NO_ERRCODE, "invalid selector line (port), probably not doing " "what was intended"); } } |