add config option to disable ANSI log colours

Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
strawberry 2024-09-29 12:27:42 -04:00
parent acb9eae707
commit 83becf013c
3 changed files with 8 additions and 1 deletions

View File

@ -363,6 +363,11 @@ allow_profile_lookup_federation_requests = true
# Defaults to "info"
#log = "info"
# controls whether logs will be outputted with ANSI colours
#
# defaults to true
#log_colors = true
# controls whether encrypted rooms and events are allowed (default true)
#allow_encryption = false

View File

@ -184,6 +184,8 @@ pub struct Config {
pub query_trusted_key_servers_first: bool,
#[serde(default = "default_log")]
pub log: String,
#[serde(default = "true_fn", alias = "log_colours")]
pub log_colors: bool,
#[serde(default = "default_openid_token_ttl")]
pub openid_token_ttl: u64,
#[serde(default)]

View File

@ -18,7 +18,7 @@ pub(crate) fn init(config: &Config) -> Result<(LogLevelReloadHandles, TracingFla
let reload_handles = LogLevelReloadHandles::default();
let console_filter = EnvFilter::try_new(&config.log).map_err(|e| err!(Config("log", "{e}.")))?;
let console_layer = tracing_subscriber::fmt::Layer::new();
let console_layer = tracing_subscriber::fmt::Layer::new().with_ansi(config.log_colors);
let (console_reload_filter, console_reload_handle) = reload::Layer::new(console_filter.clone());
reload_handles.add("console", Box::new(console_reload_handle));