diff options
author | Petr Rockai <prockai@redhat.com> | 2012-10-08 18:34:33 +0200 |
---|---|---|
committer | Petr Rockai <prockai@redhat.com> | 2012-10-08 20:35:29 +0200 |
commit | 4b4c2833d984f6b6a8dde394168b4653cdd47863 (patch) | |
tree | bfb58d79a99c5a7def0cf39c4ea61258d0136567 | |
parent | cc9c02fe68f6ee8f5f6bcf885c1ed41387778bb7 (diff) | |
download | lvm2-4b4c2833d984f6b6a8dde394168b4653cdd47863.tar.gz lvm2-4b4c2833d984f6b6a8dde394168b4653cdd47863.tar.xz lvm2-4b4c2833d984f6b6a8dde394168b4653cdd47863.zip |
libdaemon-server: Optimize logging for a fast no-output path.
-rw-r--r-- | libdaemon/server/daemon-log.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/libdaemon/server/daemon-log.c b/libdaemon/server/daemon-log.c index 837fffdc..b31bb4ea 100644 --- a/libdaemon/server/daemon-log.c +++ b/libdaemon/server/daemon-log.c @@ -52,6 +52,16 @@ void daemon_log(log_state *s, int type, const char *message) { } } +static int _type_interesting(log_state *s, int type) { + int i = 0; + while ( backend[i].id ) { + if ( (s->log_config[type] & backend[i].id) == backend[i].id ) + return 1; + ++ i; + } + return 0; +} + void daemon_logf(log_state *s, int type, const char *fmt, ...) { char *buf; va_list ap; @@ -78,12 +88,18 @@ static int _log_line(const char *line, void *baton) { void daemon_log_cft(log_state *s, int type, const char *prefix, const struct dm_config_node *n) { + if (!_type_interesting(s, type)) + return; + struct log_line_baton b = { .s = s, .type = type, .prefix = prefix }; dm_config_write_node(n, &_log_line, &b); } void daemon_log_multi(log_state *s, int type, const char *prefix, const char *msg) { + if (!_type_interesting(s, type)) + return; + struct log_line_baton b = { .s = s, .type = type, .prefix = prefix }; char *buf = dm_strdup(msg); char *pos = buf; |