systemprompt_cli/commands/infrastructure/logs/
shared.rs1use systemprompt_logging::CliService;
11use systemprompt_models::text::truncate_with_ellipsis;
12
13use super::LogEntryRow;
14
15pub use systemprompt_models::time_format::{format_optional_duration_ms, format_timestamp};
16
17pub fn cost_microdollars_to_dollars(microdollars: i64) -> f64 {
18 microdollars as f64 / 1_000_000.0
19}
20
21pub fn display_log_row(log: &LogEntryRow) {
22 let time_part = if log.timestamp.len() >= 23 {
23 &log.timestamp[11..23]
24 } else {
25 &log.timestamp
26 };
27
28 let trace_short = truncate_with_ellipsis(log.trace_id.as_str(), 8);
29
30 let line = format!(
31 "{} {} [{}] {} [{}]",
32 time_part, log.level, log.module, log.message, trace_short
33 );
34
35 match log.level.as_str() {
36 "ERROR" => CliService::error(&line),
37 "WARN" => CliService::warning(&line),
38 _ => CliService::info(&line),
39 }
40}