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

Function parse_error_log

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

Parse a log into entries, folding continuation lines into their entry. The plugin writer appends `message` unescaped, so a stack trace or a multi-paragraph error spans several physical lines. A line that does not start with a timestamp is therefore a continuation of the entry above it, not a separate entry — and dropping it would lose most of the message. Returns the entries plus the number of p

(body: &str)

Source from the content-addressed store, hash-verified

425/// Returns the entries plus the number of physical lines consumed, so the
426/// report can be honest about what fraction of the file it understood.
427fn parse_error_log(body: &str) -> (Vec<HookErrorEntry>, usize) {
428 let mut entries: Vec<HookErrorEntry> = Vec::new();
429 let mut lines = 0usize;
430
431 for line in body.lines() {
432 if line.trim().is_empty() {
433 continue;
434 }
435 lines += 1;
436
437 match parse_error_line(line) {
438 Some(entry) => entries.push(entry),
439 None => {
440 if let Some(last) = entries.last_mut() {
441 last.message = truncate_detail(&format!("{} {}", last.message, line.trim()));
442 }
443 }
444 }
445 }
446
447 (entries, lines)
448}
449
450/// Parse one log line into an entry, or `None` if it is not shaped like one.
451///

Calls 5

parse_error_lineFunction · 0.85
truncate_detailFunction · 0.85
linesMethod · 0.45
is_emptyMethod · 0.45
pushMethod · 0.45