Log message improvements
This commit is contained in:
parent
ab14d614f6
commit
a27f65743c
1 changed files with 53 additions and 68 deletions
27
lib/util.cpp
27
lib/util.cpp
|
@ -287,47 +287,36 @@ namespace Util{
|
|||
char * lineno = 0;
|
||||
char * strmNm = 0;
|
||||
char * message = 0;
|
||||
while (i < 9 && buf[i] != '|' && buf[i] != 0){++i;}
|
||||
if (buf[i] == '|'){
|
||||
while (i < 9 && buf[i] != '|' && buf[i] != 0 && buf[i] < 128){++i;}
|
||||
if (buf[i] != '|'){continue;}//on parse error, skip to next message
|
||||
buf[i] = 0;//insert null byte
|
||||
++i;
|
||||
progname = buf+i;//progname starts here
|
||||
}
|
||||
while (i < 40 && buf[i] != '|' && buf[i] != 0){++i;}
|
||||
if (buf[i] == '|'){
|
||||
if (buf[i] != '|'){continue;}//on parse error, skip to next message
|
||||
buf[i] = 0;//insert null byte
|
||||
++i;
|
||||
progpid = buf+i;//progpid starts here
|
||||
}
|
||||
while (i < 60 && buf[i] != '|' && buf[i] != 0){++i;}
|
||||
if (buf[i] == '|'){
|
||||
if (buf[i] != '|'){continue;}//on parse error, skip to next message
|
||||
buf[i] = 0;//insert null byte
|
||||
++i;
|
||||
lineno = buf+i;//lineno starts here
|
||||
}
|
||||
while (i < 180 && buf[i] != '|' && buf[i] != 0){++i;}
|
||||
if (buf[i] == '|'){
|
||||
if (buf[i] != '|'){continue;}//on parse error, skip to next message
|
||||
buf[i] = 0;//insert null byte
|
||||
++i;
|
||||
strmNm = buf+i;//stream name starts here
|
||||
}
|
||||
while (i < 380 && buf[i] != '|' && buf[i] != 0){++i;}
|
||||
if (buf[i] == '|'){
|
||||
if (buf[i] != '|'){continue;}//on parse error, skip to next message
|
||||
buf[i] = 0;//insert null byte
|
||||
++i;
|
||||
message = buf+i;//message starts here
|
||||
}
|
||||
if (!message){
|
||||
message = strmNm;
|
||||
strmNm = 0;
|
||||
if (message){i = message-buf;}
|
||||
}
|
||||
//find end of line, insert null byte
|
||||
unsigned int j = i;
|
||||
while (j < 1023 && buf[j] != '\n' && buf[j] != 0){++j;}
|
||||
buf[j] = 0;
|
||||
//print message
|
||||
if (message){
|
||||
if (callback){callback(kind, message, strmNm, true);}
|
||||
color_msg = color_end;
|
||||
if (colored){
|
||||
|
@ -361,10 +350,6 @@ namespace Util{
|
|||
dprintf(out, " (%s) ", lineno);
|
||||
}
|
||||
dprintf(out, "\n");
|
||||
}else{
|
||||
//could not be parsed as log string - print the whole thing
|
||||
dprintf(out, "%s\n", buf);
|
||||
}
|
||||
}
|
||||
fclose(output);
|
||||
close(in);
|
||||
|
|
Loading…
Add table
Reference in a new issue