add options for console tracing EnvFilter details
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
da984d49cf
commit
d921b82376
3 changed files with 28 additions and 2 deletions
|
@ -604,6 +604,15 @@
|
||||||
#
|
#
|
||||||
#log_span_events = "none"
|
#log_span_events = "none"
|
||||||
|
|
||||||
|
# configures whether CONDUWUIT_LOG EnvFilter matches values using regular
|
||||||
|
# expressions. See the tracing_subscriber documentation on Directives.
|
||||||
|
#
|
||||||
|
#log_filter_regex = true
|
||||||
|
|
||||||
|
# toggles the display of ThreadId in tracing log output
|
||||||
|
#
|
||||||
|
#log_thread_ids = false
|
||||||
|
|
||||||
# OpenID token expiration/TTL in seconds
|
# OpenID token expiration/TTL in seconds
|
||||||
#
|
#
|
||||||
# These are the OpenID tokens that are primarily used for Matrix account
|
# These are the OpenID tokens that are primarily used for Matrix account
|
||||||
|
|
|
@ -698,6 +698,19 @@ pub struct Config {
|
||||||
#[serde(default = "default_log_span_events")]
|
#[serde(default = "default_log_span_events")]
|
||||||
pub log_span_events: String,
|
pub log_span_events: String,
|
||||||
|
|
||||||
|
/// configures whether CONDUWUIT_LOG EnvFilter matches values using regular
|
||||||
|
/// expressions. See the tracing_subscriber documentation on Directives.
|
||||||
|
///
|
||||||
|
/// default: true
|
||||||
|
#[serde(default = "true_fn")]
|
||||||
|
pub log_filter_regex: bool,
|
||||||
|
|
||||||
|
/// toggles the display of ThreadId in tracing log output
|
||||||
|
///
|
||||||
|
/// default: false
|
||||||
|
#[serde(default)]
|
||||||
|
pub log_thread_ids: bool,
|
||||||
|
|
||||||
/// OpenID token expiration/TTL in seconds
|
/// OpenID token expiration/TTL in seconds
|
||||||
///
|
///
|
||||||
/// These are the OpenID tokens that are primarily used for Matrix account
|
/// These are the OpenID tokens that are primarily used for Matrix account
|
||||||
|
|
|
@ -18,11 +18,15 @@ pub(crate) type TracingFlameGuard = ();
|
||||||
pub(crate) fn init(config: &Config) -> Result<(LogLevelReloadHandles, TracingFlameGuard, Arc<capture::State>)> {
|
pub(crate) fn init(config: &Config) -> Result<(LogLevelReloadHandles, TracingFlameGuard, Arc<capture::State>)> {
|
||||||
let reload_handles = LogLevelReloadHandles::default();
|
let reload_handles = LogLevelReloadHandles::default();
|
||||||
|
|
||||||
let console_filter = EnvFilter::try_new(&config.log).map_err(|e| err!(Config("log", "{e}.")))?;
|
|
||||||
let console_span_events = fmt_span::from_str(&config.log_span_events).unwrap_or_err();
|
let console_span_events = fmt_span::from_str(&config.log_span_events).unwrap_or_err();
|
||||||
|
let console_filter = EnvFilter::builder()
|
||||||
|
.with_regex(config.log_filter_regex)
|
||||||
|
.parse(&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)
|
.with_ansi(config.log_colors)
|
||||||
.with_span_events(console_span_events);
|
.with_span_events(console_span_events)
|
||||||
|
.with_thread_ids(config.log_thread_ids);
|
||||||
let (console_reload_filter, console_reload_handle) = reload::Layer::new(console_filter.clone());
|
let (console_reload_filter, console_reload_handle) = reload::Layer::new(console_filter.clone());
|
||||||
reload_handles.add("console", Box::new(console_reload_handle));
|
reload_handles.add("console", Box::new(console_reload_handle));
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue