pub struct DatalogWriter { /* private fields */ }Expand description
Accumulates log entries for a single turn, flushing to disk after each operation.
Implementations§
Source§impl DatalogWriter
impl DatalogWriter
pub fn new(working_dir: &Path, config: &DatalogConfig) -> Self
pub fn new_with_filename_tag( working_dir: &Path, config: &DatalogConfig, filename_tag: &str, ) -> Self
Sourcepub fn set_working_dir(&mut self, dir: &Path)
pub fn set_working_dir(&mut self, dir: &Path)
Update the working directory (e.g. after /cd). Absolute / ~/
configured paths are unaffected — only the default and relative cases
follow cwd changes.
Sourcepub fn resolve_log_dir(base_dir: &Path, configured: Option<&str>) -> PathBuf
pub fn resolve_log_dir(base_dir: &Path, configured: Option<&str>) -> PathBuf
Resolve the actual directory to write datalog files into, given the
current base_dir and configured_dir. Pure function — used by
begin_turn, by runner.rs to decide where log_llm_request writes
the JSONL request dump (so both writers stay in sync), and covered by
unit tests.
The result is always <root>/<project-slug> so multiple projects don’t
collide. <root> is $ATOMCODE_HOME/datalog by default, or whatever the
user configured (absolute / ~/… / relative-to-cwd).
Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Clear the current turn log state and delete the log file if it exists. Called when user runs /clear command.
Sourcepub fn begin_turn(
&mut self,
user_message: &str,
model_name: &str,
context_window: usize,
)
pub fn begin_turn( &mut self, user_message: &str, model_name: &str, context_window: usize, )
Start a new turn: create log file, write env info + user message.
Sourcepub fn log_llm_call(&mut self)
pub fn log_llm_call(&mut self)
Log start of a new LLM round-trip (increments the turn counter). Records the duration of the previous LLM turn.
Sourcepub fn log_context_stats(
&mut self,
system_tokens: usize,
sent_tokens: usize,
dropped_tokens: usize,
_working_set_tokens: usize,
total_messages: usize,
)
pub fn log_context_stats( &mut self, system_tokens: usize, sent_tokens: usize, dropped_tokens: usize, _working_set_tokens: usize, total_messages: usize, )
Log context statistics for debugging.
Sourcepub fn log_cache_hit(&mut self, prompt_tokens: usize, cached_tokens: usize)
pub fn log_cache_hit(&mut self, prompt_tokens: usize, cached_tokens: usize)
Log prompt cache hit info (only when provider reports cached_tokens > 0).
Sourcepub fn log_token_usage(
&mut self,
prompt_tokens: usize,
completion_tokens: usize,
cached_tokens: usize,
)
pub fn log_token_usage( &mut self, prompt_tokens: usize, completion_tokens: usize, cached_tokens: usize, )
Log token usage for the current LLM round-trip.
Sourcepub fn log_llm_dump(
&mut self,
messages: &[Message],
tool_count: usize,
model: &str,
context_window: usize,
)
pub fn log_llm_dump( &mut self, messages: &[Message], tool_count: usize, model: &str, context_window: usize, )
Dump full LLM request as JSON into the datalog for debugging.
Appends to a single JSONL file (one JSON object per line) colocated
with the turn .md file: <turn_timestamp>_requests.jsonl.
Each line has the step number so you can correlate with the md.
Sourcepub fn log_tool_call(&mut self, name: &str, args: &str)
pub fn log_tool_call(&mut self, name: &str, args: &str)
Log a tool call start (within the current LLM turn).
Sourcepub fn log_tool_result(&mut self, output: &str, success: bool)
pub fn log_tool_result(&mut self, output: &str, success: bool)
Log a tool call result.
Sourcepub fn log_model_text(&mut self, text: &str)
pub fn log_model_text(&mut self, text: &str)
Log model text output between tool calls (plan, thinking, explanation).
Sourcepub fn log_warning(&mut self, warning: &str)
pub fn log_warning(&mut self, warning: &str)
Log a non-fatal advisory (e.g. provider truncation detector).
Persisting it here makes post-hoc datalog inspection useful even
when the live TUI line scrolls past — the user can grep the
markdown for **Warning:** after the run.
Auto Trait Implementations§
impl Freeze for DatalogWriter
impl RefUnwindSafe for DatalogWriter
impl Send for DatalogWriter
impl Sync for DatalogWriter
impl Unpin for DatalogWriter
impl UnsafeUnpin for DatalogWriter
impl UnwindSafe for DatalogWriter
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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