MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / parse_error_line

Function parse_error_line

atomic-agent/src/hook_health.rs:466–492  ·  view source on GitHub ↗

Parse one log line into an entry, or `None` if it is not shaped like one. Two writers append to this file with different grammars: ```text {rfc3339} {session_id} {verb} {message} # agent plugins {rfc3339} shadow-validate:{rule} view={view} {message} # git-shadow validator ``` The plugin grammar leads with the session id, so the verb is the third field; the shadow gramma

(line: &str)

Source from the content-addressed store, hash-verified

464/// A line whose first token is not a timestamp is not an entry of its own;
465/// [`parse_error_log`] folds it into the previous one.
466fn parse_error_line(line: &str) -> Option<HookErrorEntry> {
467 let mut fields = line.split_whitespace();
468 let at = fields.next()?;
469 if chrono::DateTime::parse_from_rfc3339(at).is_err() {
470 return None;
471 }
472
473 let second = fields.next().unwrap_or("");
474
475 // Everything after the verb, rebuilt so a multi-word message survives.
476 let (verb, rest): (&str, String) = if second.starts_with(SESSION_ID_PREFIX) {
477 let verb = fields.next().unwrap_or("unknown");
478 (verb, fields.collect::<Vec<_>>().join(" "))
479 } else {
480 (second, fields.collect::<Vec<_>>().join(" "))
481 };
482
483 Some(HookErrorEntry {
484 at: at.to_string(),
485 verb: if verb.is_empty() {
486 "unknown".to_string()
487 } else {
488 verb.to_string()
489 },
490 message: truncate_detail(&rest),
491 })
492}
493
494/// Group entries into error classes and build the report.
495fn aggregate(entries: &[HookErrorEntry], lines: usize, start: u64) -> HookErrors {

Callers 4

parse_error_logFunction · 0.85

Calls 3

truncate_detailFunction · 0.85
nextMethod · 0.45
is_emptyMethod · 0.45

Tested by 3