Make getlog commands less flakey
getlog {kill,none} getlog what getlog list getlog err,wrn[,...]
This commit is contained in:
40
conman.c
40
conman.c
@ -2176,14 +2176,51 @@ int LogCapture(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
argtolower(argc, argv);
|
||||
|
||||
/* Branch according to argv[1] */
|
||||
if (strcmp(argv[1], "kill") == 0) {
|
||||
if (strcmp(argv[1], "kill") == 0 || strcmp(argv[1], "none") == 0) {
|
||||
SCPrintf(pCon, eLog, "getlog %s", argv[1]);
|
||||
KillCapture(pConMaster);
|
||||
return 1;
|
||||
} else if (strcmp(argv[1], "what") == 0) {
|
||||
unsigned int code_bits = 0;
|
||||
pDynString buffer;
|
||||
code_bits = (1 << iNoCodes) - 1;
|
||||
buffer = CreateDynString(100, 100);
|
||||
for (i = 0; i < iNoCodes; ++i) {
|
||||
if (code_bits & (1 << i)) {
|
||||
if (GetDynStringLength(buffer) > 0)
|
||||
DynStringConcatChar(buffer, ',');
|
||||
DynStringConcat(buffer, OutCodeToTxt(i));
|
||||
}
|
||||
}
|
||||
SCPrintf(pCon, eLog, "getlog %s", GetCharArray(buffer));
|
||||
DeleteDynString(buffer);
|
||||
return 1;
|
||||
} else if (strcmp(argv[1], "list") == 0) {
|
||||
unsigned int code_bits = 0;
|
||||
pDynString buffer;
|
||||
code_bits = GetSICSLogHook(pConMaster);
|
||||
if (code_bits == 0) {
|
||||
SCPrintf(pCon, eLog, "getlog none");
|
||||
return 1;
|
||||
}
|
||||
buffer = CreateDynString(100, 100);
|
||||
for (i = 0; i < iNoCodes; ++i) {
|
||||
if (code_bits & (1 << i)) {
|
||||
if (GetDynStringLength(buffer) > 0)
|
||||
DynStringConcatChar(buffer, ',');
|
||||
DynStringConcat(buffer, OutCodeToTxt(i));
|
||||
}
|
||||
}
|
||||
SCPrintf(pCon, eLog, "getlog %s", GetCharArray(buffer));
|
||||
DeleteDynString(buffer);
|
||||
return 1;
|
||||
} else if (strcmp(argv[1], "all") == 0) {
|
||||
SCPrintf(pCon, eLog, "getlog all");
|
||||
AddSICSLogHook(hookFunc, "all", pConMaster);
|
||||
return 1;
|
||||
} else if (argc == 2) {
|
||||
/* must be outcode, try find it */
|
||||
SCPrintf(pCon, eLog, "getlog %s", argv[1]);
|
||||
AddSICSLogHook(hookFunc, argv[1], pConMaster);
|
||||
return 1;
|
||||
} else {
|
||||
@ -2207,6 +2244,7 @@ int LogCapture(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
strcpy(&pBuff[len], argv[i]);
|
||||
len += strlen(argv[i]);
|
||||
}
|
||||
SCPrintf(pCon, eLog, "getlog %s", pBuff);
|
||||
AddSICSLogHook(hookFunc, pBuff, pConMaster);
|
||||
if (pBuff != pBueffel)
|
||||
free(pBuff);
|
||||
|
Reference in New Issue
Block a user