pub struct JsonlReporter<W> { /* private fields */ }Expand description
Machine-readable reporter that writes one JSON object per line (JSONL).
Each AgentEvent is wrapped in an EventEnvelope with a timestamp
and serialized as a single JSON line. This format is easy to ingest in
log aggregation systems or to replay offline.
I/O and serialization errors are collected internally and can be
retrieved with take_errors.
§Example
use agentkit_reporting::JsonlReporter;
// Write JSONL to an in-memory buffer (useful in tests).
let reporter = JsonlReporter::new(Vec::new());
// Write JSONL to a file, flushing after every event.
let file = std::fs::File::create("events.jsonl")?;
let reporter = JsonlReporter::new(std::io::BufWriter::new(file));Implementations§
Source§impl<W> JsonlReporter<W>where
W: Write,
impl<W> JsonlReporter<W>where
W: Write,
Sourcepub fn with_flush_each_event(self, flush_each_event: bool) -> Self
pub fn with_flush_each_event(self, flush_each_event: bool) -> Self
Controls whether the writer is flushed after every event (builder pattern).
Sourcepub fn take_errors(&self) -> Vec<ReportError>
pub fn take_errors(&self) -> Vec<ReportError>
Drains and returns all errors accumulated during event handling.
Sourcepub fn into_inner(self) -> W
pub fn into_inner(self) -> W
Consumes the reporter and returns the underlying writer.
Trait Implementations§
Source§impl<W> LoopObserver for JsonlReporter<W>
impl<W> LoopObserver for JsonlReporter<W>
Source§fn handle_event(&self, event: AgentEvent)
fn handle_event(&self, event: AgentEvent)
Called synchronously for every
AgentEvent emitted by the loop driver.
Observers store mutable state behind interior mutability (Mutex,
atomics, channels) so the driver can share an Arc<dyn LoopObserver>
across reusable Agent starts.Auto Trait Implementations§
impl<W> !Freeze for JsonlReporter<W>
impl<W> RefUnwindSafe for JsonlReporter<W>
impl<W> Send for JsonlReporter<W>where
W: Send,
impl<W> Sync for JsonlReporter<W>where
W: Send,
impl<W> Unpin for JsonlReporter<W>where
W: Unpin,
impl<W> UnsafeUnpin for JsonlReporter<W>where
W: UnsafeUnpin,
impl<W> UnwindSafe for JsonlReporter<W>
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