Experimental Physics and Industrial Control System
J. Lewis Muir wrote:
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 see that I probably could change MAX_MESSAGE_SIZE in EPICS base at
src/libCom/error/errlog.c
but I'd rather not be running a modified EPICS base.
As a work around, I could break up the longer messages into smaller
pieces, logging each piece individually, but I would rather not. Is
there a better way to handle this?
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) {
- Replies:
- Re: Support for larger messages in IOC Error Logging facility J. Lewis Muir
- References:
- Support for larger messages in IOC Error Logging facility J. Lewis Muir
- Navigate by Date:
- Prev:
Re: calcout without update Tim Mooney
- Next:
HP8116A signal generator Eric Norum
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
<2006>
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
- Navigate by Thread:
- Prev:
Support for larger messages in IOC Error Logging facility J. Lewis Muir
- Next:
Re: Support for larger messages in IOC Error Logging facility J. Lewis Muir
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
<2006>
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025