speed up logging

don't bother processing a line, if the level is too high for any queue
This commit is contained in:
ac-stef
2017-06-27 15:15:21 +02:00
parent 7c54645785
commit 1d1230544b
3 changed files with 32 additions and 22 deletions
+7 -1
View File
@@ -76,13 +76,19 @@ void exitlogging()
enabled = false;
}
bool logcheck(int level)
{
return enabled && level >= 0 && level < ACLOG_NUM && (consolethreshold <= level || (fp && filethreshold <= level) || syslogthreshold <= level);
}
bool logline(int level, const char *msg, ...)
{
if(!enabled) return false;
if(level < 0 || level >= ACLOG_NUM) return false;
bool logtocon = consolethreshold <= level, logtofile = fp && filethreshold <= level, logtosyslog = syslogthreshold <= level;
if(!(logtocon || logtofile || logtosyslog)) return false;
defvformatstring(sf, msg, msg);
filtertext(sf, sf, FTXT__LOG);
bool logtocon = consolethreshold <= level, logtofile = fp && filethreshold <= level, logtosyslog = syslogthreshold <= level;
const char *ts = timestamp ? timestring(true, "%b %d %H:%M:%S ") : "", *ld = levelprefix[level];
char *p, *l = sf;
do