log: reorder filters as a small optimization

Reorder the filters for the journald layer. This sets the LevelFilter
last, which means tracing can disable all log statements lower than the
current level without evaluating the LogContext::exists function.

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
 [ TL: note that this is just an optimization in the subject ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Gabriel Goller 2024-07-15 17:13:14 +02:00 committed by Thomas Lamprecht
parent 5262cefd34
commit 500fb592f9

View File

@ -52,10 +52,10 @@ pub fn init_logger(
.with(
tracing_journald::layer()
.expect("Unable to open syslog")
.with_filter(log_level)
.with_filter(filter_fn(|metadata| {
LogContext::exists() || *metadata.level() == Level::ERROR
})),
}))
.with_filter(log_level),
)
.with(TasklogLayer {}.with_filter(log_level));