Refactor to set dead time as a shell variable and add documentation
This commit is contained in:
@ -399,11 +399,25 @@ Debug output can be redirected to a file with the command
|
||||
When called without a filename, debug output is directed back
|
||||
to the console.
|
||||
</p>
|
||||
<p>
|
||||
By default the debug/error output is set to be colored if the terminal allows
|
||||
it but this can be set to always colored or never colored by setting
|
||||
<code>streamDebugColored</code> to 1 or 0 respectively.
|
||||
</p>
|
||||
<p>
|
||||
When a device is disconnected StreamDevice can produce many repeated timeout
|
||||
messages. To reduce this logging you can set <code>streamErrorDeadTime</code>
|
||||
to an integer number of seconds. When this is set repeated timeout messages
|
||||
will not be printed in the specified dead time after the last message. The
|
||||
default dead time is 0, resulting in every message being printed.
|
||||
</p>
|
||||
|
||||
<h3>Example (vxWorks):</h3>
|
||||
<pre>
|
||||
streamError=1
|
||||
streamDebug=1
|
||||
streamDebugColored=1
|
||||
streamErrorDeadTime=30
|
||||
streamSetLogfile("logfile.txt")
|
||||
</pre>
|
||||
|
||||
@ -411,6 +425,8 @@ streamSetLogfile("logfile.txt")
|
||||
<pre>
|
||||
var streamError 1
|
||||
var streamDebug 1
|
||||
var streamDebugColored 1
|
||||
var streamErrorDeadTime 30
|
||||
streamSetLogfile("logfile.txt")
|
||||
</pre>
|
||||
|
||||
|
@ -27,7 +27,7 @@
|
||||
|
||||
#define Z PRINTF_SIZE_T_PREFIX
|
||||
|
||||
int DeadTime = 0;
|
||||
int streamErrorDeadTime = 0;
|
||||
|
||||
/// debug functions /////////////////////////////////////////////
|
||||
|
||||
@ -1848,11 +1848,11 @@ bool StreamCore::checkShouldPrint(ProtocolResult newErrorType)
|
||||
time(&lastErrorTime);
|
||||
return true;
|
||||
}
|
||||
else if (time(NULL) - lastErrorTime > DeadTime) {
|
||||
else if (time(NULL) - lastErrorTime > streamErrorDeadTime) {
|
||||
time(&lastErrorTime);
|
||||
if (numberOfErrors != 0) {
|
||||
error("%s: %i additional errors of the following type seen in the last %i seconds\n",
|
||||
name(), numberOfErrors, DeadTime);
|
||||
name(), numberOfErrors, streamErrorDeadTime);
|
||||
}
|
||||
numberOfErrors = 0;
|
||||
return true;
|
||||
|
@ -96,7 +96,7 @@ const unsigned long ClearOnStart = InitRun|AsyncMode|GotValue|Aborted|
|
||||
AcceptInput|AcceptEvent|BusPending;
|
||||
|
||||
// The amount of time to wait before printing duplicated messages
|
||||
extern int DeadTime;
|
||||
extern int streamErrorDeadTime;
|
||||
|
||||
struct StreamFormat;
|
||||
|
||||
|
@ -199,6 +199,7 @@ extern "C" { // needed for Windows
|
||||
epicsExportAddress(int, streamDebug);
|
||||
epicsExportAddress(int, streamError);
|
||||
epicsExportAddress(int, streamDebugColored);
|
||||
epicsExportAddress(int, streamErrorDeadTime);
|
||||
}
|
||||
|
||||
// for subroutine record
|
||||
@ -261,12 +262,6 @@ long streamSetLogfile(const char* filename)
|
||||
return OK;
|
||||
}
|
||||
|
||||
long streamMessageDeadTime(int newDeadTime)
|
||||
{
|
||||
DeadTime = newDeadTime;
|
||||
return OK;
|
||||
}
|
||||
|
||||
#ifndef EPICS_3_13
|
||||
static const iocshArg streamReloadArg0 =
|
||||
{ "recordname", iocshArgString };
|
||||
@ -304,26 +299,11 @@ void streamSetLogfileFunc (const iocshArgBuf *args)
|
||||
streamSetLogfile(args[0].sval);
|
||||
}
|
||||
|
||||
// Setting a dead time for messages at the IOC Console will cause repeated messages to only be periodically logged.
|
||||
static const iocshArg streamMessageDeadTimeArg0 =
|
||||
{ "dead time (s)", iocshArgInt };
|
||||
static const iocshArg * const streamMessageDeadTimeArgs[] =
|
||||
{ &streamMessageDeadTimeArg0 };
|
||||
static const iocshFuncDef messageDeadTimeDef =
|
||||
{ "streamMessageDeadTime", 1, streamMessageDeadTimeArgs };
|
||||
|
||||
extern "C" void messageDeadTimeFunc(const iocshArgBuf *args)
|
||||
{
|
||||
streamMessageDeadTime(args[0].ival);
|
||||
}
|
||||
|
||||
|
||||
static void streamRegistrar ()
|
||||
{
|
||||
iocshRegister(&streamReloadDef, streamReloadFunc);
|
||||
iocshRegister(&streamReportRecordDef, streamReportRecordFunc);
|
||||
iocshRegister(&streamSetLogfileDef, streamSetLogfileFunc);
|
||||
iocshRegister(&messageDeadTimeDef, messageDeadTimeFunc);
|
||||
// make streamReload available for subroutine records
|
||||
registryFunctionAdd("streamReload",
|
||||
(REGISTRYFUNCTION)streamReloadSub);
|
||||
|
@ -33,6 +33,7 @@ if (@ARGV[0] eq "-3.13") {
|
||||
print "variable(streamDebug, int)\n";
|
||||
print "variable(streamError, int)\n";
|
||||
print "variable(streamDebugColored, int)\n";
|
||||
print "variable(streamErrorDeadTime, int)\n";
|
||||
print "registrar(streamRegistrar)\n";
|
||||
if ($asyn) { print "registrar(AsynDriverInterfaceRegistrar)\n"; }
|
||||
}
|
||||
|
Reference in New Issue
Block a user