pub struct RingFile { /* private fields */ }Expand description
RingFile keeps [RingBuffer] within thread local, to prevent lock contention affecting program execution. When program hang or panic, you can call dump() to collect the logs into file or stdout.
Implementations§
Source§impl RingFile
impl RingFile
Sourcepub fn new(buf_size: usize, file_path: Option<Box<Path>>) -> Self
pub fn new(buf_size: usize, file_path: Option<Box<Path>>) -> Self
§Arguments:
-
buf_size: buffer size per thread
-
file_path: If contains a path, the target is a file, otherwise will write to stdout.
Sourcepub fn dump(&self) -> Result<()>
pub fn dump(&self) -> Result<()>
collect all the buffers, sort by timestamp and dump to disk or stdout.
pub fn write(&self, ts: i64, content: String)
Auto Trait Implementations§
impl !Freeze for RingFile
impl RefUnwindSafe for RingFile
impl Send for RingFile
impl Sync for RingFile
impl Unpin for RingFile
impl !UnwindSafe for RingFile
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