File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -81,6 +81,10 @@ fn format_size(bytes: u64) -> String {
8181 }
8282}
8383
84+ fn log_file_label ( count : usize ) -> & ' static str {
85+ if count == 1 { "log file" } else { "log files" }
86+ }
87+
8488impl LogsCli {
8589 /// Run the logs command.
8690 pub async fn run ( self ) -> Result < ( ) > {
@@ -344,8 +348,9 @@ impl LogsCli {
344348
345349 if cleared > 0 {
346350 println ! (
347- "Cleared {} log file(s) ({}) older than {} days." ,
351+ "Cleared {} {} ({}) older than {} days." ,
348352 cleared,
353+ log_file_label( cleared) ,
349354 format_size( cleared_bytes) ,
350355 self . keep_days
351356 ) ;
@@ -406,6 +411,13 @@ mod tests {
406411 assert_eq ! ( format_size( MB ) , "1.00 MB" ) ;
407412 }
408413
414+ #[ test]
415+ fn test_log_file_label ( ) {
416+ assert_eq ! ( log_file_label( 0 ) , "log files" ) ;
417+ assert_eq ! ( log_file_label( 1 ) , "log file" ) ;
418+ assert_eq ! ( log_file_label( 2 ) , "log files" ) ;
419+ }
420+
409421 // =========================================================================
410422 // Tests for LogsCli default values
411423 // =========================================================================
You can’t perform that action at this time.
0 commit comments