diff options
-rw-r--r-- | plugins/imsolaris/imsolaris.c | 20 | ||||
-rw-r--r-- | runtime/msg.h | 1 | ||||
-rw-r--r-- | runtime/parser.c | 29 |
3 files changed, 22 insertions, 28 deletions
diff --git a/plugins/imsolaris/imsolaris.c b/plugins/imsolaris/imsolaris.c index a2238a29..67aa479d 100644 --- a/plugins/imsolaris/imsolaris.c +++ b/plugins/imsolaris/imsolaris.c @@ -127,7 +127,6 @@ solaris_readLog(int fd) uchar bufRcv[4096+1]; uchar *pRcv = NULL; /* receive buffer */ char errStr[1024]; - uchar fmtBuf[10240]; // TODO: use better solution assert(logfd >= 0); @@ -158,32 +157,21 @@ solaris_readLog(int fd) dbgprintf("imsolaris: getmsg() returns %d\n", ret); dbgprintf("imsolaris: message from log socket: #%d: %s\n", fd, pRcv); if (1) {//iRcvd > 0) { - // TODO: use hdr info! This whole section is a work-around to get - // it going. -#if 0 CHKiRet(msgConstruct(&pMsg)); //MsgSetFlowControlType(pMsg, eFLOWCTL_FULL_DELAY); MsgSetInputName(pMsg, pInputName); MsgSetRawMsg(pMsg, (char*)pRcv, strlen((char*)pRcv)); - MsgSetMSGoffs(pMsg, 0); /* we do not have a header... */ MsgSetHOSTNAME(pMsg, glbl.GetLocalHostName(), ustrlen(glbl.GetLocalHostName())); - //MsgSetTAG(pMsg, pInfo->pszTag, pInfo->lenTag); - //pMsg->iFacility = LOG_FAC(pInfo->iFacility); - //pMsg->iSeverity = LOG_PRI(pInfo->iSeverity); + pMsg->iFacility = LOG_FAC(hdr.pri); + pMsg->iSeverity = LOG_PRI(hdr.pri); pMsg->bParseHOSTNAME = 0; + pMsg->msgFlags = NEEDS_PARSING | NO_PRI_IN_RAW; CHKiRet(submitMsg(pMsg)); -#else - iRcvd = snprintf((char*)fmtBuf, sizeof(fmtBuf), "<%d>%s", hdr.pri, (char*) pRcv); - parseAndSubmitMessage(glbl.GetLocalHostName(), - (uchar*)"127.0.0.1", fmtBuf, - iRcvd, 0, - 0, pInputName, NULL, 0); -#endif } else if (iRcvd < 0 && errno != EINTR) { int en = errno; rs_strerror_r(en, errStr, sizeof(errStr)); dbgprintf("imsolaris: stream error: %d = %s.\n", errno, errStr); - //errmsg.LogError(en, NO_ERRCODE, "imsolaris: socket error UNIX"); + errmsg.LogError(en, NO_ERRCODE, "imsolaris: stream input error: %s", errStr); } finalize_it: diff --git a/runtime/msg.h b/runtime/msg.h index 3a02365b..f10c919c 100644 --- a/runtime/msg.h +++ b/runtime/msg.h @@ -130,6 +130,7 @@ struct msg { #define MARK 0x008 /* this message is a mark */ #define NEEDS_PARSING 0x010 /* raw message, must be parsed before processing can be done */ #define PARSE_HOSTNAME 0x020 /* parse the hostname during message parsing */ +#define NO_PRI_IN_RAW 0x040 /* rawmsg does not include a PRI (Solaris!), but PRI is already set correctly in the msg object */ /* function prototypes diff --git a/runtime/parser.c b/runtime/parser.c index 36e88ebd..810bf42b 100644 --- a/runtime/parser.c +++ b/runtime/parser.c @@ -287,19 +287,24 @@ rsRetVal parseMsg(msg_t *pMsg) msg = pMsg->pszRawMsg; pri = DEFUPRI; iPriText = 0; - if(*msg == '<') { - /* while we process the PRI, we also fill the PRI textual representation - * inside the msg object. This may not be ideal from an OOP point of view, - * but it offers us performance... - */ - pri = 0; - while(--lenMsg > 0 && isdigit((int) *++msg)) { - pri = 10 * pri + (*msg - '0'); + if(pMsg->msgFlags & NO_PRI_IN_RAW) { + /* In this case, simply do so as if the pri would be right at top */ + MsgSetAfterPRIOffs(pMsg, 0); + } else { + if(*msg == '<') { + /* while we process the PRI, we also fill the PRI textual representation + * inside the msg object. This may not be ideal from an OOP point of view, + * but it offers us performance... + */ + pri = 0; + while(--lenMsg > 0 && isdigit((int) *++msg)) { + pri = 10 * pri + (*msg - '0'); + } + if(*msg == '>') + ++msg; + if(pri & ~(LOG_FACMASK|LOG_PRIMASK)) + pri = DEFUPRI; } - if(*msg == '>') - ++msg; - if(pri & ~(LOG_FACMASK|LOG_PRIMASK)) - pri = DEFUPRI; } pMsg->iFacility = LOG_FAC(pri); pMsg->iSeverity = LOG_PRI(pri); |