- do not allow logger to write more than once per period
- fixed bug in statistics.c
This commit is contained in:
23
logsetup.c
23
logsetup.c
@@ -14,6 +14,7 @@ static hdbCallbackReturn LoggerUpdateCallback(pHdb node,
|
||||
hdbValue value;
|
||||
pHdbDataMessage mm = NULL;
|
||||
pHdbDataSearch dsm = NULL;
|
||||
time_t now;
|
||||
|
||||
if ((dsm = GetHdbDataSearchMessage(message)) != NULL) {
|
||||
if (dsm->testPtr == loggerID) {
|
||||
@@ -29,9 +30,12 @@ static hdbCallbackReturn LoggerUpdateCallback(pHdb node,
|
||||
|
||||
value = *(mm->v);
|
||||
|
||||
str = formatValue(value, node);
|
||||
LoggerWrite(logger, time(NULL), LoggerPeriod(logger), GetCharArray(str));
|
||||
DeleteDynString(str);
|
||||
time(&now);
|
||||
if (now > LoggerLastTime(logger)) { /* never write more than once per second */
|
||||
str = formatValue(value, node);
|
||||
LoggerWrite(logger, time(NULL), LoggerPeriod(logger), GetCharArray(str));
|
||||
DeleteDynString(str);
|
||||
}
|
||||
return hdbContinue;
|
||||
}
|
||||
|
||||
@@ -50,6 +54,7 @@ static int LogSetup(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
if (argc < 2) {
|
||||
SCPrintf(pCon, eError,
|
||||
"ERROR: should be: logsetup <node> [<period> [<filename>]]");
|
||||
/* or logsetup <node> clear */
|
||||
return 0;
|
||||
}
|
||||
if (strcasecmp(argv[1], "basepath") == 0) {
|
||||
@@ -77,10 +82,6 @@ static int LogSetup(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
SCPrintf(pCon, eError, "ERROR: %s not found", argv[1]);
|
||||
return 0;
|
||||
}
|
||||
period = 0;
|
||||
if (argc > 2) {
|
||||
period = atoi(argv[2]);
|
||||
}
|
||||
if (argc > 3) {
|
||||
snprintf(buf, sizeof buf, "%s", argv[3]);
|
||||
} else {
|
||||
@@ -101,6 +102,14 @@ static int LogSetup(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
numeric = 0;
|
||||
}
|
||||
logger = FindHdbCallbackData(node, loggerID);
|
||||
period = 0;
|
||||
if (argc > 2) {
|
||||
if (logger != NULL && strcasecmp(argv[2], "clear") == 0) {
|
||||
LoggerWrite(logger, time(NULL), LoggerPeriod(logger), "");
|
||||
return 1;
|
||||
}
|
||||
period = atoi(argv[2]);
|
||||
}
|
||||
if (logger != 0) { /* logger exists already, changed only period */
|
||||
LoggerSetPeriod(logger, period);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user