From 500fb592f908a2c38455a47b3d99a378ae15b096 Mon Sep 17 00:00:00 2001 From: Gabriel Goller Date: Mon, 15 Jul 2024 17:13:14 +0200 Subject: [PATCH] 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 [ TL: note that this is just an optimization in the subject ] Signed-off-by: Thomas Lamprecht --- proxmox-log/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/proxmox-log/src/lib.rs b/proxmox-log/src/lib.rs index f4f24e0c..99006515 100644 --- a/proxmox-log/src/lib.rs +++ b/proxmox-log/src/lib.rs @@ -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));