![]() |
![]() ![]()
Experimental Physics and
| ||||||||||||||||
|
I have a situation where I would like to log messages via the IOC Error Logging facility (e.g. errlogPrintf) that are longer than the current maximum message size of 256 characters (as of EPICS 3.14.8.2). I don't see any obvious reason why we can't make MAX_MESSAGE_SIZE an initialization parameter and add a 2-argument init routine to allow it to be set. Or if I submitted a patch to allow a larger message size perhaps by changing the errlogInit function to allow a second argument of "int msgsize", would it likely be accepted or are there reasons against this? If you would like to test out the attached (untested) patch and let me know if it solves the issue, I'll see that it gets into R3.14.9. To increase the message size, call errlogInit2(0, maxMsgSize) before something else calls errlogInit(0). - Andrew -- There is considerable overlap between the intelligence of the smartest bears and the dumbest tourists -- Yosemite National Park Ranger Index: errlog.c =================================================================== RCS file: /net/phoebus/epicsmgr/cvsroot/epics/base/src/libCom/error/errlog.c,v retrieving revision 1.35.2.16 diff -u -b -r1.35.2.16 errlog.c --- errlog.c 22 Mar 2005 21:48:43 -0000 1.35.2.16 +++ errlog.c 1 Nov 2006 19:32:27 -0000 @@ -86,6 +86,7 @@ msgNode *pnextSend; int errlogInitFailed; int buffersize; + int maxMsgSize; int sevToLog; int toConsole; int missedMessages; @@ -152,7 +153,7 @@ isOkToBlock = epicsThreadIsOkToBlock(); pbuffer = msgbufGetFree(isOkToBlock); if(!pbuffer) return(0); - nchar = tvsnPrint(pbuffer,MAX_MESSAGE_SIZE,pFormat?pFormat:"",pvar); + nchar = tvsnPrint(pbuffer,pvtData.maxMsgSize,pFormat?pFormat:"",pvar); msgbufSetSize(nchar); return nchar; } @@ -195,7 +196,7 @@ if(pvtData.atExit) return 0; pbuffer = msgbufGetFree(1); if(!pbuffer) return(0); - nchar = tvsnPrint(pbuffer,MAX_MESSAGE_SIZE,pFormat?pFormat:"",pvar); + nchar = tvsnPrint(pbuffer,pvtData.maxMsgSize,pFormat?pFormat:"",pvar); msgbufSetSize(nchar); return nchar; } @@ -248,7 +249,7 @@ if(!pnext) return(0); nchar = sprintf(pnext,"sevr=%s ",errlogGetSevEnumString(severity)); pnext += nchar; totalChar += nchar; - nchar = tvsnPrint(pnext,MAX_MESSAGE_SIZE-totalChar-1,pFormat,pvar); + nchar = tvsnPrint(pnext,pvtData.maxMsgSize-totalChar-1,pFormat,pvar); pnext += nchar; totalChar += nchar; if(pnext[-1] != '\n') { strcpy(pnext,"\n"); @@ -366,7 +367,7 @@ pnext += nchar; totalChar += nchar; } va_start (pvar, pformat); - nchar = tvsnPrint(pnext,MAX_MESSAGE_SIZE,pformat,pvar); + nchar = tvsnPrint(pnext,pvtData.maxMsgSize,pformat,pvar); va_end (pvar); if(nchar>0) { pnext += nchar; @@ -386,15 +387,20 @@ return; } +struct initArgs { + int bufsize; + int maxMsgSize; +}; + LOCAL void errlogInitPvt(void *arg) { - int bufsize = *(int *)arg; + struct initArgs *pconfig = (struct initArgs *) arg; void *pbuffer; epicsThreadId tid; pvtData.errlogInitFailed = TRUE; - if(bufsize<BUFFER_SIZE) bufsize = BUFFER_SIZE; - pvtData.buffersize = bufsize; + pvtData.buffersize = pconfig->bufsize; + pvtData.maxMsgSize = pconfig->maxMsgSize; ellInit(&pvtData.listenerList); ellInit(&pvtData.msgQueue); pvtData.toConsole = TRUE; @@ -428,17 +434,26 @@ /*Note that exitHandler must destroy waitForExit*/ } -epicsShareFunc int epicsShareAPI errlogInit(int bufsize) +epicsShareFunc int epicsShareAPI errlogInit2(int bufsize, int maxMsgSize) { static epicsThreadOnceId errlogOnceFlag=EPICS_THREAD_ONCE_INIT; + struct initArgs config; - epicsThreadOnce(&errlogOnceFlag,errlogInitPvt,(void *)&bufsize); + if (bufsize < BUFFER_SIZE) bufsize = BUFFER_SIZE; + config.bufsize = bufsize; + if (maxMsgSize < MAX_MESSAGE_SIZE) maxMsgSize = MAX_MESSAGE_SIZE; + config.maxMsgSize = maxMsgSize; + epicsThreadOnce(&errlogOnceFlag, errlogInitPvt, (void *)&config); if(pvtData.errlogInitFailed) { fprintf(stderr,"errlogInit failed\n"); exit(1); } return(0); } +epicsShareFunc int epicsShareAPI errlogInit(int bufsize) +{ + return errlogInit2(bufsize, MAX_MESSAGE_SIZE); +} epicsShareFunc void epicsShareAPI errlogFlush(void) { int count; @@ -504,7 +519,7 @@ msgNode *plast; plast = (msgNode *)ellLast(&pvtData.msgQueue); - needed = MAX_MESSAGE_SIZE + sizeof(msgNode) + MAX_ALIGNMENT; + needed = pvtData.maxMsgSize + sizeof(msgNode) + MAX_ALIGNMENT; remaining = pvtData.buffersize - ((plast->message - pbuffer) + plast->length); if(needed < remaining) {
| ||||||||||||||||
ANJ, 02 Sep 2010 |
![]() · Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing · |