use systemprompt_logging::{CliService, LogLevel};
use systemprompt_models::text::truncate_with_ellipsis;
use super::LogEntryRow;
pub use systemprompt_models::time_format::{format_optional_duration_ms, format_timestamp};
pub fn cost_microdollars_to_dollars(microdollars: i64) -> f64 {
microdollars as f64 / 1_000_000.0
}
pub fn display_log_row(log: &LogEntryRow) {
let time_part = if log.timestamp.len() >= 23 {
&log.timestamp[11..23]
} else {
&log.timestamp
};
let trace_short = truncate_with_ellipsis(log.trace_id.as_str(), 8);
let line = format!(
"{} {} [{}] {} [{}]",
time_part, log.level, log.module, log.message, trace_short
);
print_level_line(log.level, &line);
}
pub fn print_level_line(level: LogLevel, line: &str) {
match level {
LogLevel::Error => CliService::error(line),
LogLevel::Warn => CliService::warning(line),
LogLevel::Info | LogLevel::Debug | LogLevel::Trace => CliService::info(line),
}
}