Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/cortex-cli/src/logs_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ fn format_size(bytes: u64) -> String {
}
}

fn log_file_label(count: usize) -> &'static str {
if count == 1 { "log file" } else { "log files" }
}

impl LogsCli {
/// Run the logs command.
pub async fn run(self) -> Result<()> {
Expand Down Expand Up @@ -344,8 +348,9 @@ impl LogsCli {

if cleared > 0 {
println!(
"Cleared {} log file(s) ({}) older than {} days.",
"Cleared {} {} ({}) older than {} days.",
cleared,
log_file_label(cleared),
format_size(cleared_bytes),
self.keep_days
);
Expand Down Expand Up @@ -406,6 +411,13 @@ mod tests {
assert_eq!(format_size(MB), "1.00 MB");
}

#[test]
fn test_log_file_label() {
assert_eq!(log_file_label(0), "log files");
assert_eq!(log_file_label(1), "log file");
assert_eq!(log_file_label(2), "log files");
}

// =========================================================================
// Tests for LogsCli default values
// =========================================================================
Expand Down