From 4210a91d597287dcd9ab7ac06e2259c7246c03fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodolphe=20Br=C3=A9ard?= Date: Thu, 23 Mar 2023 14:57:24 +0100 Subject: [PATCH] Adapt the logs to OpenSMTPD --- src/logs.rs | 13 ++++++++++--- src/main.rs | 1 - 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/logs.rs b/src/logs.rs index 1ffd3e0..2727784 100644 --- a/src/logs.rs +++ b/src/logs.rs @@ -1,10 +1,17 @@ use env_logger::{Builder, Env, Target}; +use std::io::Write; pub fn init_log_system() { - let env = Env::new() - .filter_or(crate::LOG_LEVEL_ENV_VAR, "warn") - .write_style_or(crate::LOG_STYLE_ENV_VAR, "never"); + let env = Env::new().filter_or(crate::LOG_LEVEL_ENV_VAR, "warn"); let mut builder = Builder::from_env(env); + builder.format(|buf, record| { + writeln!( + buf, + "{}: {}", + record.level().to_string().to_lowercase(), + record.args() + ) + }); builder.target(Target::Stderr); builder.init(); } diff --git a/src/main.rs b/src/main.rs index 028e8ea..aba6272 100644 --- a/src/main.rs +++ b/src/main.rs @@ -11,7 +11,6 @@ use stdin_reader::StdinReader; const DEFAULT_BUFF_SIZE: usize = 1024; const LOG_LEVEL_ENV_VAR: &str = "OPENSMTPD_FILTER_DKIMOUT_LOG_LEVEL"; -const LOG_STYLE_ENV_VAR: &str = "OPENSMTPD_FILTER_DKIMOUT_LOG_STYLE"; #[macro_export] macro_rules! display_bytes {