fn rotate_output_file_to_date(
    creation_date: &DateTime<Local>,
    config: &FileLogWriterConfig,
) -> Result<(), FlexiLoggerError> {
    let current_path = get_filepath(Some(CURRENT_INFIX), &config.filename_config);

    let mut rotated_path = get_filepath(
        Some(&creation_date.format("_r%Y-%m-%d_%H-%M-%S").to_string()),
        &config.filename_config,
    );
    // Check that the target of rename does not yet exist
    let mut i = 0_u32;
    while (*rotated_path).exists() {
        rotated_path = get_filepath(
            Some(
                &creation_date
                    .format("_r%Y-%m-%d_%H-%M-%S")
                    .to_string()
                    .add(&format!("-restart-{}", i)),
            ),
            &config.filename_config,
        );
        i += 1;
    }

    match std::fs::rename(&current_path, &rotated_path) {
        Ok(()) => Ok(()),
        Err(e) => {
            if e.kind() == std::io::ErrorKind::NotFound {
                // current did not exist, so we had nothing to do
                Ok(())
            } else {
                Err(FlexiLoggerError::Io(e))
            }
        }
    }
}
// Moves the current file to the timestamp of the CURRENT file's creation date.
Moves the current file to the timestamp of the CURRENT file's creation date.
Moves the current file to the timestamp of the CURRENT file ' s creation date .
fn rotate_output_file_to_date(
    creation_date: &DateTime<Local>,
    config: &FileLogWriterConfig,
) -> Result<(), FlexiLoggerError> {
    let current_path = get_filepath(Some(CURRENT_INFIX), &config.filename_config);
    let mut rotated_path = get_filepath(
        Some(&creation_date.format("_r%Y-%m-%d_%H-%M-%S").to_string()),
        &config.filename_config,
    );
    // Check that the target of rename does not yet exist
    let mut i = 0_u32;
    while (*rotated_path).exists() {
        rotated_path = get_filepath(
            Some(
                &creation_date
                    .format("_r%Y-%m-%d_%H-%M-%S")
                    .to_string()
                    .add(&format!("-restart-{}", i)),
            ),
            &config.filename_config,
        );
        i += 1;
    }
    match std::fs::rename(&current_path, &rotated_path) {
        Ok(()) => Ok(()),
        Err(e) => {
            if e.kind() == std::io::ErrorKind::NotFound {
                // current did not exist, so we had nothing to do
                Ok(())
            } else {
                Err(FlexiLoggerError::Io(e))
            }
        }
    }
}
fn rotate_output_file_to_date ( creation_date : & DateTime < Local > , config : & FileLogWriterConfig , ) -> Result < ( ) , FlexiLoggerError > { let current_path = get_filepath ( Some ( CURRENT_INFIX ) , & config . filename_config ) ; let mut rotated_path = get_filepath ( Some ( & creation_date . format ( " " ) . to_string ( ) ) , & config . filename_config , ) ; // Check that the target of rename does not yet exist let mut i = 0_u32 ; while ( * rotated_path ) . exists ( ) { rotated_path = get_filepath ( Some ( & creation_date . format ( " " ) . to_string ( ) . add ( & format ! ( " " i ) ) , ) , & config . filename_config , ) ; i += 1 ; } match std :: fs :: rename ( & current_path , & rotated_path ) { Ok ( ( ) ) => Ok ( ( ) ) , Err ( e ) => { if e . kind ( ) == std :: io :: ErrorKind :: NotFound { // current did not exist, so we had nothing to do Ok ( ( ) ) } else { Err ( FlexiLoggerError :: Io ( e ) ) } } } }
Moves the current file to the timestamp of the CURRENT file's creation date.
Moves the current file to the timestamp of the CURRENT file ' s creation date .
creation_date
&DateTime<Local>
config
&FileLogWriterConfig
creation_date
&DateTime<Local>
config
&FileLogWriterConfig