From c5bbaf470ac992d2af29b3ad60358575b3a34c27 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Thu, 16 Jun 2022 14:53:03 +0100 Subject: [PATCH] arti: logging config: Replace a manual Debug impl --- Cargo.lock | 1 + crates/arti/Cargo.toml | 1 + crates/arti/src/logging.rs | 11 ++++------- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 52a577fe7..bff91ed51 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -89,6 +89,7 @@ dependencies = [ "clap", "config", "derive_builder_fork_arti", + "educe", "fs-mistrust", "futures", "itertools", diff --git a/crates/arti/Cargo.toml b/crates/arti/Cargo.toml index 03b6bd065..681783cf2 100644 --- a/crates/arti/Cargo.toml +++ b/crates/arti/Cargo.toml @@ -30,6 +30,7 @@ cfg-if = "1.0.0" clap = "2.33.0" config = { version = "0.13", default-features = false, features = ["toml"] } derive_builder = { version = "0.11", package = "derive_builder_fork_arti" } +educe = "0.4.6" fs-mistrust = { path = "../fs-mistrust", version = "0.2.0" } futures = "0.3.14" notify = "4.0" diff --git a/crates/arti/src/logging.rs b/crates/arti/src/logging.rs index 9810fd63c..c6836a61c 100644 --- a/crates/arti/src/logging.rs +++ b/crates/arti/src/logging.rs @@ -2,6 +2,7 @@ use anyhow::{anyhow, Context, Result}; use derive_builder::Builder; +use educe::Educe; use fs_mistrust::Mistrust; use serde::{Deserialize, Serialize}; use std::path::Path; @@ -96,7 +97,8 @@ pub struct LogfileConfig { } /// How often to rotate a log file -#[derive(Debug, Clone, Serialize, Deserialize, Copy, Eq, PartialEq)] +#[derive(Debug, Clone, Educe, Serialize, Deserialize, Copy, Eq, PartialEq)] +#[educe(Default)] #[non_exhaustive] #[serde(rename_all = "lowercase")] pub enum LogRotation { @@ -105,15 +107,10 @@ pub enum LogRotation { /// Rotate logs hourly Hourly, /// Never rotate the log + #[educe(Default)] Never, } -impl Default for LogRotation { - fn default() -> Self { - Self::Never - } -} - impl LogfileConfig { /// Return a new [`LogfileConfigBuilder`] pub fn builder() -> LogfileConfigBuilder {