logmsg: extend oldmg string buffer to 20 entries to avoid logging repeated obsoleted by msgs
This commit is contained in:
parent
54798cd06a
commit
10a6a28ea8
@ -121,15 +121,20 @@ void log_debug_set(int value) {
|
|||||||
void logmsg(int level, const char *msg, ...) {
|
void logmsg(int level, const char *msg, ...) {
|
||||||
|
|
||||||
va_list ap;
|
va_list ap;
|
||||||
static char oldmsg[1024] = "";
|
static char oldmsg[20][256];
|
||||||
|
static int curroldmsg = 0;
|
||||||
char newmsg[1024];
|
char newmsg[1024];
|
||||||
|
int i;
|
||||||
|
|
||||||
va_start(ap, msg);
|
va_start(ap, msg);
|
||||||
vsnprintf((char*)&newmsg, 1024, msg, ap);
|
vsnprintf((char*)&newmsg, 1024, msg, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
if (strncmp(newmsg,(char*)&oldmsg,1024) != 0) /* only log the same message once */
|
for (i = 0; i < 20; i++) {
|
||||||
{
|
/* only log the same message once */
|
||||||
|
if (!strncmp(newmsg,(char*)&(oldmsg[i]),256)) return;
|
||||||
|
}
|
||||||
|
|
||||||
switch (level) {
|
switch (level) {
|
||||||
case LOG_MARK:
|
case LOG_MARK:
|
||||||
fprintf(stderr,"Info: ******************************\n");
|
fprintf(stderr,"Info: ******************************\n");
|
||||||
@ -148,7 +153,9 @@ void logmsg(int level, const char *msg, ...) {
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
strncpy(oldmsg,newmsg,1024);
|
if ((level == LOG_WARNING) || (level == LOG_ERROR)) {
|
||||||
|
strncpy(oldmsg[curroldmsg++],newmsg,256);
|
||||||
|
if (curroldmsg >= 20) curroldmsg = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user