diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2008-03-06 09:44:16 +0000 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2008-03-06 09:44:16 +0000 |
commit | 15e8b33eedce5985701f0b8c949125999fcf789b (patch) | |
tree | f44a9af22478c5f8a31a347fb5b13b1ab47f8828 | |
parent | 680e899ce9bf84b2406620f4dc1a35986568c97a (diff) | |
download | rsyslog-15e8b33eedce5985701f0b8c949125999fcf789b.tar.gz rsyslog-15e8b33eedce5985701f0b8c949125999fcf789b.tar.xz rsyslog-15e8b33eedce5985701f0b8c949125999fcf789b.zip |
fixed a few remaining logerror() calls - thanks to Michael Biebl for
pointing that out
-rw-r--r-- | module-template.h | 1 | ||||
-rw-r--r-- | plugins/imtemplate/imtemplate.c | 18 | ||||
-rw-r--r-- | plugins/omlibdbi/omlibdbi.c | 15 | ||||
-rw-r--r-- | plugins/ommysql/ommysql.c | 11 | ||||
-rw-r--r-- | plugins/ompgsql/ompgsql.c | 13 |
5 files changed, 28 insertions, 30 deletions
diff --git a/module-template.h b/module-template.h index 3dae7021..3478acd0 100644 --- a/module-template.h +++ b/module-template.h @@ -27,6 +27,7 @@ #define MODULE_TEMPLATE_H_INCLUDED 1 #include "modules.h" +#include "obj.h" #include "objomsr.h" #include "threads.h" diff --git a/plugins/imtemplate/imtemplate.c b/plugins/imtemplate/imtemplate.c index 33938045..6d29c4f1 100644 --- a/plugins/imtemplate/imtemplate.c +++ b/plugins/imtemplate/imtemplate.c @@ -227,22 +227,10 @@ CODESTARTrunInput /* All rsyslog objects (see other modules, e.g. msg.c) are available * to your here. Some useful things are: * - * logerror("string"); - * logs an error message as syslogd + * errmsg.LogError(NO_ERRCODE, format-string, ... params ...); + * logs an error message as syslogd, just as printf, e.g. + * errmsg.LogError(NO_ERRCODE, "Error %d occured during %s", 1, "test"); * - * logerror("string with %s", uchar* ptr) - * just like logerror, but with a variable pointer to a string - * - * The safe way to obtain a system error message is: - * char errStr[1024]; // 1024 is just a (relatively) safe bet... - * rs_strerror_r(errno, errStr, sizeof(errStr)); - * logerror("error occured: %s", errStr); // optional, of course... - * - * To log something to the debug log, simply use - * dbgprintf("fmtstring %d, %s\n", 4711, "like in printf"); - * Be sure to include a newline '\n' at the end of the message, else - * the debug log will become quite cluttered... - * * There are several ways how a message can be enqueued. This part of the * interface is currently underspecified. Have a look at the function definitions * in syslogd.c (sorry, folks...). diff --git a/plugins/omlibdbi/omlibdbi.c b/plugins/omlibdbi/omlibdbi.c index 557e2284..299180c0 100644 --- a/plugins/omlibdbi/omlibdbi.c +++ b/plugins/omlibdbi/omlibdbi.c @@ -47,12 +47,14 @@ #include "template.h" #include "module-template.h" #include "debug.h" +#include "errmsg.h" MODULE_TYPE_OUTPUT /* internal structures */ DEF_OMOD_STATIC_DATA +DEFobjCurrIf(errmsg) static int bDbiInitialized = 0; /* dbi_initialize() can only be called one - this keeps track of it */ typedef struct _instanceData { @@ -136,7 +138,7 @@ reportDBError(instanceData *pData, int bSilent) /* output log message */ errno = 0; if(pData->conn == NULL) { - logerror("unknown DB error occured - could not obtain connection handle"); + errmsg.LogError(NO_ERRCODE, "unknown DB error occured - could not obtain connection handle"); } else { /* we can ask dbi for the error description... */ uDBErrno = dbi_conn_error(pData->conn, &pszDbiErr); snprintf(errMsg, sizeof(errMsg)/sizeof(char), "db error (%d): %s\n", uDBErrno, pszDbiErr); @@ -144,7 +146,7 @@ reportDBError(instanceData *pData, int bSilent) dbgprintf("libdbi, DBError(silent): %s\n", errMsg); else { pData->uLastDBErrno = uDBErrno; - logerror(errMsg); + errmsg.LogError(NO_ERRCODE, "%s", errMsg); } } @@ -170,10 +172,10 @@ static rsRetVal initConn(instanceData *pData, int bSilent) iDrvrsLoaded = dbi_initialize((char*) dbiDrvrDir); # endif if(iDrvrsLoaded == 0) { - logerror("libdbi error: libdbi or libdbi drivers not present on this system - suspending."); + errmsg.LogError(NO_ERRCODE, "libdbi error: libdbi or libdbi drivers not present on this system - suspending."); ABORT_FINALIZE(RS_RET_SUSPENDED); } else if(iDrvrsLoaded < 0) { - logerror("libdbi error: libdbi could not be initialized - suspending."); + errmsg.LogError(NO_ERRCODE, "libdbi error: libdbi could not be initialized - suspending."); ABORT_FINALIZE(RS_RET_SUSPENDED); } bDbiInitialized = 1; /* we are done for the rest of our existence... */ @@ -185,7 +187,7 @@ static rsRetVal initConn(instanceData *pData, int bSilent) pData->conn = dbi_conn_new((char*)pData->drvrName); # endif if(pData->conn == NULL) { - logerror("can not initialize libdbi connection"); + errmsg.LogError(NO_ERRCODE, "can not initialize libdbi connection"); iRet = RS_RET_SUSPENDED; } else { /* we could get the handle, now on with work... */ /* Connect to database */ @@ -275,7 +277,7 @@ CODE_STD_STRING_REQUESTparseSelectorAct(1) /* no create the instance based on what we currently have */ if(drvrName == NULL) { - logerror("omlibdbi: no db driver name given - action can not be created"); + errmsg.LogError(NO_ERRCODE, "omlibdbi: no db driver name given - action can not be created"); ABORT_FINALIZE(RS_RET_NO_DRIVERNAME); } @@ -361,6 +363,7 @@ BEGINmodInit() CODESTARTmodInit *ipIFVersProvided = CURR_MOD_IF_VERSION; /* we only support the current interface specification */ CODEmodInit_QueryRegCFSLineHdlr + CHKiRet(objUse(errmsg, CORE_COMPONENT)); CHKiRet(omsdRegCFSLineHdlr( (uchar *)"actionlibdbidriverdirectory", 0, eCmdHdlrGetWord, NULL, &dbiDrvrDir, STD_LOADABLE_MODULE_ID)); CHKiRet(omsdRegCFSLineHdlr( (uchar *)"actionlibdbidriver", 0, eCmdHdlrGetWord, NULL, &drvrName, STD_LOADABLE_MODULE_ID)); CHKiRet(omsdRegCFSLineHdlr( (uchar *)"actionlibdbihost", 0, eCmdHdlrGetWord, NULL, &host, STD_LOADABLE_MODULE_ID)); diff --git a/plugins/ommysql/ommysql.c b/plugins/ommysql/ommysql.c index e9c0b043..5876b754 100644 --- a/plugins/ommysql/ommysql.c +++ b/plugins/ommysql/ommysql.c @@ -43,12 +43,14 @@ #include "template.h" #include "ommysql.h" #include "module-template.h" +#include "errmsg.h" MODULE_TYPE_OUTPUT /* internal structures */ DEF_OMOD_STATIC_DATA +DEFobjCurrIf(errmsg) typedef struct _instanceData { MYSQL *f_hmysql; /* handle to MySQL */ @@ -118,7 +120,7 @@ static void reportDBError(instanceData *pData, int bSilent) /* output log message */ errno = 0; if(pData->f_hmysql == NULL) { - logerror("unknown DB error occured - could not obtain MySQL handle"); + errmsg.LogError(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, @@ -127,7 +129,7 @@ static void reportDBError(instanceData *pData, int bSilent) dbgprintf("mysql, DBError(silent): %s\n", errMsg); else { pData->uLastMySQLErrno = uMySQLErrno; - logerror(errMsg); + errmsg.LogError(NO_ERRCODE, "%s", errMsg); } } @@ -148,7 +150,7 @@ static rsRetVal initMySQL(instanceData *pData, int bSilent) pData->f_hmysql = mysql_init(NULL); if(pData->f_hmysql == NULL) { - logerror("can not initialize MySQL handle"); + errmsg.LogError(NO_ERRCODE, "can not initialize MySQL handle"); iRet = RS_RET_SUSPENDED; } else { /* we could get the handle, now on with work... */ /* Connect to database */ @@ -273,7 +275,7 @@ CODE_STD_STRING_REQUESTparseSelectorAct(1) * Retries make no sense. */ if (iMySQLPropErr) { - logerror("Trouble with MySQL connection properties. -MySQL logging disabled"); + errmsg.LogError(NO_ERRCODE, "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!) */ @@ -298,6 +300,7 @@ BEGINmodInit() CODESTARTmodInit *ipIFVersProvided = CURR_MOD_IF_VERSION; /* we only support the current interface specification */ CODEmodInit_QueryRegCFSLineHdlr + CHKiRet(objUse(errmsg, CORE_COMPONENT)); ENDmodInit /* * vi:set ai: diff --git a/plugins/ompgsql/ompgsql.c b/plugins/ompgsql/ompgsql.c index abe5ff13..9e84956a 100644 --- a/plugins/ompgsql/ompgsql.c +++ b/plugins/ompgsql/ompgsql.c @@ -42,12 +42,14 @@ #include "template.h" #include "ompgsql.h" #include "module-template.h" +#include "errmsg.h" MODULE_TYPE_OUTPUT /* internal structures */ DEF_OMOD_STATIC_DATA +DEFobjCurrIf(errmsg) typedef struct _instanceData { PGconn *f_hpgsql; /* handle to PgSQL */ @@ -116,7 +118,7 @@ static void reportDBError(instanceData *pData, int bSilent) /* output log message */ errno = 0; if(pData->f_hpgsql == NULL) { - logerror("unknown DB error occured - could not obtain PgSQL handle"); + errmsg.LogError(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, @@ -125,7 +127,7 @@ static void reportDBError(instanceData *pData, int bSilent) dbgprintf("pgsql, DBError(silent): %s\n", errMsg); else { pData->eLastPgSQLStatus = ePgSQLStatus; - logerror(errMsg); + errmsg.LogError(NO_ERRCODE, "%s", errMsg); } } @@ -153,7 +155,7 @@ static rsRetVal initPgSQL(instanceData *pData, int bSilent) iRet = RS_RET_SUSPENDED; } - return iRet; + RETiRet; } @@ -189,7 +191,7 @@ finalize_it: pData->eLastPgSQLStatus = CONNECTION_OK; /* reset error for error supression */ } - return iRet; + RETiRet; } @@ -267,7 +269,7 @@ CODE_STD_STRING_REQUESTparseSelectorAct(1) * Retries make no sense. */ if (iPgSQLPropErr) { - logerror("Trouble with PgSQL connection properties. -PgSQL logging disabled"); + errmsg.LogError(NO_ERRCODE, "Trouble with PgSQL connection properties. -PgSQL logging disabled"); ABORT_FINALIZE(RS_RET_INVALID_PARAMS); } else { CHKiRet(initPgSQL(pData, 0)); @@ -291,6 +293,7 @@ BEGINmodInit() CODESTARTmodInit *ipIFVersProvided = CURR_MOD_IF_VERSION; /* we only support the current interface specification */ CODEmodInit_QueryRegCFSLineHdlr + CHKiRet(objUse(errmsg, CORE_COMPONENT)); ENDmodInit /* * vi:set ai: |