Skip to main content

EventLoopLogger

Struct EventLoopLogger 

Source
pub struct EventLoopLogger { /* private fields */ }
Expand description

Logger for recording event loop execution.

This logger writes a human-readable log of the event loop’s progression:

  • which effects ran
  • what events were emitted
  • how long each effect took
  • what phase/iteration/retry context was active

The log is always-on (not just for crashes) and is written to .agent/logs-<run_id>/event_loop.log for easy diagnosis.

Redaction: This logger must never include sensitive content like prompts, agent outputs, secrets, or credentials.

Implementations§

Source§

impl EventLoopLogger

Source

pub fn new() -> Self

Create a new EventLoopLogger.

The sequence counter starts at 1 for the first logged effect.

Source

pub fn from_existing_log( workspace: &dyn Workspace, log_path: &Path, ) -> Result<Self, Error>

Create a new EventLoopLogger that continues from an existing log file.

This reads the last sequence number from the existing log file and starts the counter from last_seq + 1. This is important for resume scenarios to maintain monotonically increasing sequence numbers within a run.

§Arguments
  • workspace - Workspace implementation for reading the log file
  • log_path - Path to the existing event loop log file
§Returns
  • Ok(EventLoopLogger) - Logger initialized with next sequence number
  • Err(std::io::Error) - If reading the log file fails
§Behavior
  • If the log file doesn’t exist or is empty, starts at seq=1
  • If the log file exists, reads the last line to extract the sequence number
  • If the last line doesn’t match the expected format, starts at seq=1
  • The sequence counter is set to last_seq + 1 to continue the sequence
Source

pub fn log_effect(&mut self, params: LogEffectParams<'_>) -> Result<(), Error>

Log an effect execution.

This writes a single line to the event loop log with the following format:

<seq> ts=<rfc3339> phase=<Phase> effect=<Effect> event=<Event> [extra=[E1,E2]] [ctx=k1=v1,k2=v2] ms=<N>

Example:

1 ts=2026-02-06T14:03:27.123Z phase=Development effect=InvokePrompt event=PromptCompleted ms=1234
2 ts=2026-02-06T14:03:28.456Z phase=Development effect=WriteFile event=FileWritten ctx=file=PLAN.md ms=12
§Best-Effort Logging

Write failures are returned but do not affect pipeline correctness. This is intentional: event loop logging is observability-only and must not affect pipeline correctness. If logging fails (e.g., disk full, permissions), the pipeline continues execution.

Callers who want visibility into logging failures should check the return value and log to the pipeline logger if desired.

Trait Implementations§

Source§

impl Default for EventLoopLogger

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.