pub struct JsonlHookSink { /* private fields */ }Expand description
A HookSink that appends each event as a JSON line to a file.
The file is created (along with any missing parent directories) on the
first emitted event. Each line is a JSON object of the form
{"at": "<ISO 8601 timestamp>", "event": {...}}.
Concurrent emit calls serialize on an internal mutex so
that each JSON event is written and flushed as a complete line; without that
lock, overlapping write_all calls can interleave partial lines and corrupt
the JSONL log (see issue #4739).
Implementations§
Source§impl JsonlHookSink
impl JsonlHookSink
Sourcepub fn new(path: PathBuf) -> Self
pub fn new(path: PathBuf) -> Self
Create a new sink that writes to the file at path.
Parent directories are created lazily on the first HookSink::emit
call.
Trait Implementations§
Source§impl HookSink for JsonlHookSink
impl HookSink for JsonlHookSink
Auto Trait Implementations§
impl !Freeze for JsonlHookSink
impl !RefUnwindSafe for JsonlHookSink
impl Send for JsonlHookSink
impl Sync for JsonlHookSink
impl Unpin for JsonlHookSink
impl UnsafeUnpin for JsonlHookSink
impl UnwindSafe for JsonlHookSink
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