Skip to content

Commit

Permalink
fix(console): make retain_for default to 6s if not specfied (#383)
Browse files Browse the repository at this point in the history
Fixes #382
  • Loading branch information
abusch authored and hawkw committed Sep 29, 2023
1 parent 9ce60ec commit 0a6012b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions tokio-console/src/config.rs
Expand Up @@ -121,6 +121,12 @@ pub enum OptionalCmd {
#[derive(Debug, Clone, Copy, Deserialize)]
struct RetainFor(Option<Duration>);

impl Default for RetainFor {
fn default() -> Self {
Self(Some(Duration::from_secs(6)))
}
}

impl fmt::Display for RetainFor {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self.0 {
Expand Down Expand Up @@ -320,7 +326,7 @@ impl Config {
}

pub(crate) fn retain_for(&self) -> Option<Duration> {
self.retain_for.as_ref().and_then(|value| value.0)
self.retain_for.unwrap_or_default().0
}

pub(crate) fn target_addr(&self) -> Uri {
Expand Down Expand Up @@ -390,7 +396,7 @@ impl Default for Config {
target_addr: Some(default_target_addr()),
env_filter: Some(tracing_subscriber::EnvFilter::new("off")),
log_directory: Some(default_log_directory()),
retain_for: Some(RetainFor(Some(Duration::from_secs(6)))),
retain_for: Some(RetainFor::default()),
view_options: ViewOptions::default(),
subcmd: None,
}
Expand Down

0 comments on commit 0a6012b

Please sign in to comment.