add observability infrastructure for cli subcmds

This commit is contained in:
Charles Hall 2024-10-10 14:30:13 -07:00
parent b93c39ee93
commit b03c2a15b3
No known key found for this signature in database
GPG key ID: 7B8E0645816E07CF
5 changed files with 96 additions and 10 deletions

View file

@ -180,20 +180,34 @@ impl Display for ListenConfig {
}
}
#[derive(Copy, Clone, Default, Debug, Deserialize)]
#[derive(Copy, Clone, Default, Debug, Deserialize, clap::ValueEnum)]
#[serde(rename_all = "snake_case")]
pub(crate) enum LogFormat {
/// Use the [`tracing_subscriber::fmt::format::Pretty`] formatter
/// Multiple lines per event, includes all information
Pretty,
/// Use the [`tracing_subscriber::fmt::format::Full`] formatter
/// One line per event, includes most information
#[default]
Full,
/// Use the [`tracing_subscriber::fmt::format::Compact`] formatter
/// One line per event, includes less information
Compact,
/// Use the [`tracing_subscriber::fmt::format::Json`] formatter
/// One JSON object per line per event, includes most information
Json,
}
impl Display for LogFormat {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
LogFormat::Pretty => write!(f, "pretty"),
LogFormat::Full => write!(f, "full"),
LogFormat::Compact => write!(f, "compact"),
LogFormat::Json => write!(f, "json"),
}
}
}
#[derive(Clone, Debug, Deserialize)]
#[serde(default)]
pub(crate) struct TurnConfig {
@ -404,7 +418,7 @@ fn default_max_request_size() -> u32 {
20 * 1024 * 1024
}
fn default_tracing_filter() -> EnvFilterClone {
pub(crate) fn default_tracing_filter() -> EnvFilterClone {
"info,ruma_state_res=warn"
.parse()
.expect("hardcoded env filter should be valid")