pub struct RotationManager { /* private fields */ }Expand description
Manages log file rotation and retention.
Tracks file size and time, rotates files when thresholds are reached, and applies retention policies to clean up old files.
Implementations§
Source§impl RotationManager
impl RotationManager
Sourcepub fn new(
base_path: PathBuf,
policy: RotationPolicy,
retention: Option<usize>,
) -> Self
pub fn new( base_path: PathBuf, policy: RotationPolicy, retention: Option<usize>, ) -> Self
Creates a new rotation manager.
§Arguments
base_path- Path to the log filepolicy- Rotation policy (size, time, or both)retention- Maximum number of rotated files to keep (None = unlimited)
Sourcepub fn should_rotate(&mut self, additional_size: u64) -> bool
pub fn should_rotate(&mut self, additional_size: u64) -> bool
Sourcepub fn rotate(&mut self) -> Result<PathBuf>
pub fn rotate(&mut self) -> Result<PathBuf>
Rotates the log file by renaming it with a timestamp.
Creates a new file with the original name and applies retention policy.
§Returns
Path to the rotated file, or an error if rotation fails
Sourcepub fn update_size(&mut self, size: u64)
pub fn update_size(&mut self, size: u64)
Updates the current file size by adding the specified bytes.
§Arguments
size- Number of bytes to add to current size
Sourcepub fn current_size(&self) -> u64
pub fn current_size(&self) -> u64
Returns the current file size in bytes.
Auto Trait Implementations§
impl Freeze for RotationManager
impl RefUnwindSafe for RotationManager
impl Send for RotationManager
impl Sync for RotationManager
impl Unpin for RotationManager
impl UnwindSafe for RotationManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more