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