MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / format_log_line_plain

Function format_log_line_plain

crates/openshell-tui/src/ui/sandbox_logs.rs:405–422  ·  view source on GitHub ↗

Format a log line as plain text for clipboard copy. Produces the same layout as `render_log_line()` but without styles or truncation: `HH:MM:SS {source:<7} {level:<5} {message} [key=value ...]`

(log: &LogLine)

Source from the content-addressed store, hash-verified

403/// Produces the same layout as `render_log_line()` but without styles or
404/// truncation: `HH:MM:SS {source:<7} {level:<5} {message} [key=value ...]`
405pub fn format_log_line_plain(log: &LogLine) -> String {
406 let ts = format_short_time(log.timestamp_ms);
407 let mut s = format!("{ts} {:<7} {:<5} {}", log.source, log.level, log.message);
408
409 if !log.fields.is_empty() {
410 let ordered = ordered_fields(log);
411 for (k, v) in &ordered {
412 if !v.is_empty() {
413 s.push(' ');
414 s.push_str(k);
415 s.push('=');
416 s.push_str(v);
417 }
418 }
419 }
420
421 s
422}
423
424#[cfg(test)]
425mod tests {

Calls 4

ordered_fieldsFunction · 0.85
pushMethod · 0.80
format_short_timeFunction · 0.70
is_emptyMethod · 0.45