new function streamSetLogfile to set debug log file in script or at run-time
This commit is contained in:
@ -18,6 +18,7 @@
|
|||||||
* *
|
* *
|
||||||
***************************************************************/
|
***************************************************************/
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
#include "StreamCore.h"
|
#include "StreamCore.h"
|
||||||
#include "StreamError.h"
|
#include "StreamError.h"
|
||||||
|
|
||||||
@ -237,6 +238,24 @@ long streamReload(const char* recordname)
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
long streamSetLogfile(const char* filename)
|
||||||
|
{
|
||||||
|
FILE *oldfile, *newfile = NULL;
|
||||||
|
if (filename)
|
||||||
|
{
|
||||||
|
newfile = fopen(filename, "w");
|
||||||
|
if (!newfile)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Opening file %s failed: %s\n", filename, strerror(errno));
|
||||||
|
return ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
oldfile = StreamDebugFile;
|
||||||
|
StreamDebugFile = newfile;
|
||||||
|
if (oldfile) fclose(oldfile);
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef EPICS_3_13
|
#ifndef EPICS_3_13
|
||||||
static const iocshArg streamReloadArg0 =
|
static const iocshArg streamReloadArg0 =
|
||||||
{ "recordname", iocshArgString };
|
{ "recordname", iocshArgString };
|
||||||
@ -262,10 +281,23 @@ void streamReportRecordFunc (const iocshArgBuf *args)
|
|||||||
streamReportRecord(args[0].sval);
|
streamReportRecord(args[0].sval);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const iocshArg streamSetLogfileArg0 =
|
||||||
|
{ "filename", iocshArgString };
|
||||||
|
static const iocshArg * const streamSetLogfileArgs[] =
|
||||||
|
{ &streamSetLogfileArg0 };
|
||||||
|
static const iocshFuncDef streamSetLogfileDef =
|
||||||
|
{ "streamSetLogfile", 1, streamSetLogfileArgs };
|
||||||
|
|
||||||
|
void streamSetLogfileFunc (const iocshArgBuf *args)
|
||||||
|
{
|
||||||
|
streamSetLogfile(args[0].sval);
|
||||||
|
}
|
||||||
|
|
||||||
static void streamRegistrar ()
|
static void streamRegistrar ()
|
||||||
{
|
{
|
||||||
iocshRegister(&streamReloadDef, streamReloadFunc);
|
iocshRegister(&streamReloadDef, streamReloadFunc);
|
||||||
iocshRegister(&streamReportRecordDef, streamReportRecordFunc);
|
iocshRegister(&streamReportRecordDef, streamReportRecordFunc);
|
||||||
|
iocshRegister(&streamSetLogfileDef, streamSetLogfileFunc);
|
||||||
// make streamReload available for subroutine records
|
// make streamReload available for subroutine records
|
||||||
registryFunctionAdd("streamReload",
|
registryFunctionAdd("streamReload",
|
||||||
(REGISTRYFUNCTION)streamReloadSub);
|
(REGISTRYFUNCTION)streamReloadSub);
|
||||||
@ -276,6 +308,8 @@ static void streamRegistrar ()
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
epicsExportRegistrar(streamRegistrar);
|
epicsExportRegistrar(streamRegistrar);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // !EPICS_3_13
|
#endif // !EPICS_3_13
|
||||||
|
|
||||||
// driver support ////////////////////////////////////////////////////////
|
// driver support ////////////////////////////////////////////////////////
|
||||||
|
@ -60,10 +60,6 @@ endif
|
|||||||
|
|
||||||
PROD_LIBS += $(EPICS_BASE_IOC_LIBS)
|
PROD_LIBS += $(EPICS_BASE_IOC_LIBS)
|
||||||
|
|
||||||
# Write StreamDevice debug output to this file
|
|
||||||
# If unset output goes to stdout
|
|
||||||
CPPFLAGS += -DDEBUGFILE=StreamDebug.log
|
|
||||||
|
|
||||||
# switch off annoying rset warnings in 3.16+
|
# switch off annoying rset warnings in 3.16+
|
||||||
CPPFLAGS += -DUSE_TYPED_RSET
|
CPPFLAGS += -DUSE_TYPED_RSET
|
||||||
|
|
||||||
@ -74,6 +70,6 @@ clean:
|
|||||||
else
|
else
|
||||||
clean::
|
clean::
|
||||||
endif
|
endif
|
||||||
$(RM) core* StreamDebug.log
|
$(RM) core* *.log
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
@ -32,6 +32,9 @@ asynOctetSetOutputEos "terminal",0,"\r\n"
|
|||||||
#load the records
|
#load the records
|
||||||
dbLoadRecords "example.db","PREFIX=DZ"
|
dbLoadRecords "example.db","PREFIX=DZ"
|
||||||
|
|
||||||
|
#log debug output to file
|
||||||
|
#streamSetLogfile StreamDebug.log
|
||||||
|
|
||||||
#lots(!) of debug output before iocInit
|
#lots(!) of debug output before iocInit
|
||||||
#var streamDebug 1
|
#var streamDebug 1
|
||||||
|
|
||||||
|
@ -8,6 +8,9 @@ drvAsynIPPortConfigure web epics.web.psi.ch:80 0 1
|
|||||||
|
|
||||||
dbLoadRecords regexp.db
|
dbLoadRecords regexp.db
|
||||||
|
|
||||||
|
#log debug output to file
|
||||||
|
#streamSetLogfile StreamDebug.log
|
||||||
|
|
||||||
iocInit
|
iocInit
|
||||||
#var streamDebug 1
|
#var streamDebug 1
|
||||||
|
|
||||||
|
@ -14,7 +14,10 @@ drvAsynIPPortConfigure "L0", "localhost:40000"
|
|||||||
#load the records
|
#load the records
|
||||||
dbLoadRecords "simple.db","P=DZ,BUS=L0 28"
|
dbLoadRecords "simple.db","P=DZ,BUS=L0 28"
|
||||||
|
|
||||||
|
#log debug output to file
|
||||||
|
#streamSetLogfile StreamDebug.log
|
||||||
|
|
||||||
iocInit
|
iocInit
|
||||||
|
|
||||||
#enable debug output
|
#enable debug output
|
||||||
var streamDebug 1
|
#var streamDebug 1
|
||||||
|
@ -19,15 +19,9 @@
|
|||||||
|
|
||||||
#include "epicsThread.h"
|
#include "epicsThread.h"
|
||||||
#include "iocsh.h"
|
#include "iocsh.h"
|
||||||
#include "devStream.h"
|
|
||||||
|
|
||||||
int main(int argc,char *argv[])
|
int main(int argc,char *argv[])
|
||||||
{
|
{
|
||||||
#ifdef DEBUGFILE
|
|
||||||
#define STR2(x) #x
|
|
||||||
#define STR(x) STR2(x)
|
|
||||||
StreamDebugFile = fopen(STR(DEBUGFILE), "w");
|
|
||||||
#endif
|
|
||||||
if(argc>=2) {
|
if(argc>=2) {
|
||||||
iocsh(argv[1]);
|
iocsh(argv[1]);
|
||||||
epicsThreadSleep(.2);
|
epicsThreadSleep(.2);
|
||||||
|
@ -8,5 +8,10 @@ epicsEnvSet "STREAM_PROTOCOL_PATH", "."
|
|||||||
drvAsynIPPortConfigure "terminal", "localhost:40000"
|
drvAsynIPPortConfigure "terminal", "localhost:40000"
|
||||||
|
|
||||||
dbLoadRecords "test.db","P=TEST"
|
dbLoadRecords "test.db","P=TEST"
|
||||||
|
|
||||||
|
#log debug output to file
|
||||||
|
#streamSetLogfile StreamDebug.log
|
||||||
|
|
||||||
iocInit
|
iocInit
|
||||||
|
|
||||||
#var streamDebug 1
|
#var streamDebug 1
|
||||||
|
Reference in New Issue
Block a user