use std::{io::Write, path::Path};
pub use file_rotate::{
compression::Compression,
suffix::{AppendCount, AppendTimestamp},
ContentLimit,
};
use file_rotate::{suffix::SuffixScheme, FileRotate};
pub struct RotatingFile<S: SuffixScheme> {
inner: FileRotate<S>,
}
impl<S: SuffixScheme> RotatingFile<S> {
pub fn new<P>(
path: P,
suffix_scheme: S,
content_limit: ContentLimit,
compression: Compression,
) -> Self
where
P: AsRef<Path>,
{
Self {
inner: FileRotate::new(
path,
suffix_scheme,
content_limit,
compression,
#[cfg(unix)]
None,
),
}
}
}
impl<S: SuffixScheme> Write for RotatingFile<S> {
fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
self.inner.write(buf)
}
fn flush(&mut self) -> std::io::Result<()> {
self.inner.flush()
}
}