Merge pull request #467 from chme/logging

[logger] Return early if severity or domain do not match
This commit is contained in:
ejurgensen 2017-12-17 16:01:44 +01:00 committed by GitHub
commit 37e923bf74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 0 deletions

View File

@ -164,6 +164,11 @@ DPRINTF(int severity, int domain, const char *fmt, ...)
{
va_list ap;
// If domain and severity do not match the current log configuration, return early to
// safe some unnecessary code execution (tiny performance gain)
if (logger_initialized && (!((1 << domain) & logdomains) || (severity > threshold)))
return;
va_start(ap, fmt);
vlogger(severity, domain, fmt, ap);
va_end(ap);