]> git.ipfire.org Git - thirdparty/libvirt.git/commit
log: support logging using shell wildcard syntax
authorDaniel P. Berrangé <berrange@redhat.com>
Fri, 20 Apr 2018 16:38:56 +0000 (17:38 +0100)
committerDaniel P. Berrangé <berrange@redhat.com>
Fri, 11 May 2018 16:08:06 +0000 (17:08 +0100)
commitcbb0fd3cfdc287f6f4653ef1f04a7cfb2ea51b27
treeac89f0a5ebae70a70ed322ba2907ee3b6b3c2e0e
parent4a239d150901df82ee70e59b3eed43aeeb961f12
log: support logging using shell wildcard syntax

Rather than specialcasing handling of the '*' character, use fnmatch()
to get normal shell wildcard syntax, as described in 'man glob(7)'.

To get an indication of the performance impact of using globs instead
of plain string matches, a test program was written. The list of all
260 log categories was extracted from the source. Then a typical log
filters setup was picked by creating an array of the strings "qemu",
"security", "util", "cgroup", "event", "object". Every filter string
was matched against every log category. Timing information showed that
using strstr() this took 8 microseconds, while fnmatch() took 114
microseconds.

IOW, fnmatch is 14 times slower than our existing strstr check. These
numbers show a worst case scenario that will never be hit, because it
is rare that every log category would have data output. The log category
matches are cached, so each category is only checked once no matter how
many log statements are emitted. IOW despite being slower, this will
be lost in the noise and have no consequence on real world logging
performance.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
src/util/virlog.c