From 9efcaecf2d4851ab3957c282ddd5d719dd835050 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20CORTIER?= Date: Tue, 5 Sep 2023 11:31:53 -0400 Subject: [PATCH] Code review --- tracing-appender/src/rolling.rs | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/tracing-appender/src/rolling.rs b/tracing-appender/src/rolling.rs index 37d617beac..b9bd86de65 100644 --- a/tracing-appender/src/rolling.rs +++ b/tracing-appender/src/rolling.rs @@ -103,7 +103,7 @@ pub struct RollingFileAppender { #[derive(Debug)] pub struct RollingWriter<'a> { inner: RwLockReadGuard<'a, File>, - current_size: Arc, + current_size: &'a AtomicU64, } #[derive(Debug)] @@ -269,7 +269,7 @@ impl<'a> tracing_subscriber::fmt::writer::MakeWriter<'a> for RollingFileAppender RollingWriter { inner: self.writer.read(), - current_size: Arc::clone(&self.state.current_size), + current_size: &self.state.current_size, } } } @@ -546,6 +546,22 @@ impl Rotation { } } + /// Provides a minutely and size-based rotation. + pub const fn minutely_with_max_bytes(number_of_bytes: u64) -> Self { + Self { + timed: Timed::Minutely, + max_bytes: Some(number_of_bytes), + } + } + + /// Provides a hourly and size-based rotation. + pub const fn hourly_with_max_bytes(number_of_bytes: u64) -> Self { + Self { + timed: Timed::Hourly, + max_bytes: Some(number_of_bytes), + } + } + /// Provides a daily and size-based rotation. pub const fn daily_with_max_bytes(number_of_bytes: u64) -> Self { Self {