diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2009-06-12 09:57:50 +0200 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2009-06-12 09:57:50 +0200 |
commit | 7f7e5ef75a6183c3b625afe58984343f9b7997be (patch) | |
tree | 5819d3f42dc5a9037cef5071bcc147d3d3b1c28f | |
parent | 0917edf26da9055c6dc160aafca97896daea3e6c (diff) | |
download | rsyslog-7f7e5ef75a6183c3b625afe58984343f9b7997be.tar.gz rsyslog-7f7e5ef75a6183c3b625afe58984343f9b7997be.tar.xz rsyslog-7f7e5ef75a6183c3b625afe58984343f9b7997be.zip |
improved config error messages
now contain a copy of the config line that (most likely) caused the error
-rw-r--r-- | ChangeLog | 2 | ||||
-rw-r--r-- | runtime/conf.c | 16 |
2 files changed, 14 insertions, 4 deletions
@@ -1,5 +1,7 @@ --------------------------------------------------------------------------- Version 4.3.2 [DEVEL] (rgerhards), 2009-??-?? +- improved config error messages: now contain a copy of the config line + that (most likely) caused the error - added a generic network stream server (in addition to rather specific syslog tcp server) - added ability for the UDP output action to rebind its send socket after diff --git a/runtime/conf.c b/runtime/conf.c index 014d5a9a..412a756d 100644 --- a/runtime/conf.c +++ b/runtime/conf.c @@ -71,6 +71,7 @@ #include "ctok_token.h" #include "rule.h" #include "ruleset.h" +#include "unicode-helper.h" #ifdef OS_SOLARIS # define NAME_MAX MAXNAMELEN @@ -396,7 +397,6 @@ finalize_it: static rsRetVal processConfFile(uchar *pConfFile) { - DEFiRet; int iLnNbr = 0; FILE *cf; rule_t *pCurrRule = NULL; @@ -405,6 +405,9 @@ processConfFile(uchar *pConfFile) uchar *cline; int i; int bHadAnError = 0; + uchar *pszOrgLine = NULL; + size_t lenLine; + DEFiRet; ASSERT(pConfFile != NULL); if((cf = fopen((char*)pConfFile, "r")) == NULL) { @@ -417,9 +420,12 @@ processConfFile(uchar *pConfFile) while (fgets((char*)cline, sizeof(cbuf) - (cline - cbuf), cf) != NULL) { ++iLnNbr; /* drop LF - TODO: make it better, replace fgets(), but its clean as it is */ - if(cline[strlen((char*)cline)-1] == '\n') { - cline[strlen((char*)cline) -1] = '\0'; + lenLine = ustrlen(cline); + if(cline[lenLine-1] == '\n') { + cline[lenLine-1] = '\0'; } + free(pszOrgLine); + pszOrgLine = ustrdup(cline); /* save if needed for errmsg, NULL ptr is OK */ /* check for end-of-section, comments, strip off trailing * spaces and newline character. */ @@ -464,7 +470,7 @@ processConfFile(uchar *pConfFile) dbgprintf("config line NOT successfully processed\n"); snprintf((char*)szErrLoc, sizeof(szErrLoc) / sizeof(uchar), "%s, line %d", pConfFile, iLnNbr); - errmsg.LogError(0, NO_ERRCODE, "the last error occured in %s", (char*)szErrLoc); + errmsg.LogError(0, NO_ERRCODE, "the last error occured in %s:\"%s\"", (char*)szErrLoc, (char*)pszOrgLine); bHadAnError = 1; } } @@ -488,6 +494,8 @@ finalize_it: iRet, pConfFile, errStr); } + free(pszOrgLine); + if(bHadAnError && (iRet == RS_RET_OK)) { /* a bit dirty, enhance in future releases */ iRet = RS_RET_NONFATAL_CONFIG_ERR; } |