fn try_new(
        config: &FileLogWriterConfig,
        o_rotation_config: &Option<RotationConfig>,
    ) -> Result<FileLogWriterState, FlexiLoggerError> {
        let (log_file, o_rotation_state) = match o_rotation_config {
            None => {
                let (log_file, _created_at, _p_path) = open_log_file(config, false)?;
                (log_file, None)
            }
            Some(rotate_config) => {
                // first rotate, then open the log file
                let naming_state = match rotate_config.naming {
                    Naming::Timestamps => {
                        if !config.append {
                            rotate_output_file_to_date(
                                &get_creation_date(&get_filepath(
                                    Some(CURRENT_INFIX),
                                    &config.filename_config,
                                ))?,
                                config,
                            )?;
                        }
                        NamingState::CreatedAt
                    }
                    Naming::Numbers => {
                        let mut rotation_state = get_highest_rotate_idx(&config.filename_config);
                        if !config.append {
                            rotation_state = rotate_output_file_to_idx(rotation_state, config)?;
                        }
                        NamingState::IdxState(rotation_state)
                    }
                };
                let (log_file, created_at, p_path) = open_log_file(config, true)?;

                let cleanup = rotate_config.cleanup;

                let roll_state = match &rotate_config.criterion {
                    Criterion::Age(age) => RollState::Age(*age),
                    Criterion::Size(size) => {
                        let written_bytes = if config.append {
                            std::fs::metadata(&p_path)?.len()
                        } else {
                            0
                        };
                        RollState::Size(*size, written_bytes)
                    } // max_size, current_size
                };

                (
                    log_file,
                    Some(RotationState {
                        naming_state,
                        roll_state,
                        created_at,
                        cleanup,
                    }),
                )
            }
        };

        Ok(FileLogWriterState {
            o_log_file: Some(log_file),
            o_rotation_state,
            line_ending: if config.use_windows_line_ending {
                b"\r\n"
            } else {
                b"\n"
            },
        })
    }
// If rotate, the logger writes into a file with infix `_rCURRENT`.
If rotate, the logger writes into a file with infix `_rCURRENT`.
If rotate the logger writes into a file with infix ` _rCURRENT ` .
fn try_new(
        config: &FileLogWriterConfig,
        o_rotation_config: &Option<RotationConfig>,
    ) -> Result<FileLogWriterState, FlexiLoggerError> {
        let (log_file, o_rotation_state) = match o_rotation_config {
            None => {
                let (log_file, _created_at, _p_path) = open_log_file(config, false)?;
                (log_file, None)
            }
            Some(rotate_config) => {
                // first rotate, then open the log file
                let naming_state = match rotate_config.naming {
                    Naming::Timestamps => {
                        if !config.append {
                            rotate_output_file_to_date(
                                &get_creation_date(&get_filepath(
                                    Some(CURRENT_INFIX),
                                    &config.filename_config,
                                ))?,
                                config,
                            )?;
                        }
                        NamingState::CreatedAt
                    }
                    Naming::Numbers => {
                        let mut rotation_state = get_highest_rotate_idx(&config.filename_config);
                        if !config.append {
                            rotation_state = rotate_output_file_to_idx(rotation_state, config)?;
                        }
                        NamingState::IdxState(rotation_state)
                    }
                };
                let (log_file, created_at, p_path) = open_log_file(config, true)?;
                let cleanup = rotate_config.cleanup;
                let roll_state = match &rotate_config.criterion {
                    Criterion::Age(age) => RollState::Age(*age),
                    Criterion::Size(size) => {
                        let written_bytes = if config.append {
                            std::fs::metadata(&p_path)?.len()
                        } else {
                            0
                        };
                        RollState::Size(*size, written_bytes)
                    } // max_size, current_size
                };
                (
                    log_file,
                    Some(RotationState {
                        naming_state,
                        roll_state,
                        created_at,
                        cleanup,
                    }),
                )
            }
        };
        Ok(FileLogWriterState {
            o_log_file: Some(log_file),
            o_rotation_state,
            line_ending: if config.use_windows_line_ending {
                b"\r\n"
            } else {
                b"\n"
            },
        })
    }
fn try_new ( config : & FileLogWriterConfig , o_rotation_config : & Option < RotationConfig > , ) -> Result < FileLogWriterState , FlexiLoggerError > { let ( log_file , o_rotation_state ) = match o_rotation_config { None => { let ( log_file , _created_at , _p_path ) = open_log_file ( config , false ) ? ; ( log_file , None ) } Some ( rotate_config ) => { // first rotate, then open the log file let naming_state = match rotate_config . naming { Naming :: Timestamps => { if ! config . append { rotate_output_file_to_date ( & get_creation_date ( & get_filepath ( Some ( CURRENT_INFIX ) , & config . filename_config , ) ) ? , config , ) ? ; } NamingState :: CreatedAt } Naming :: Numbers => { let mut rotation_state = get_highest_rotate_idx ( & config . filename_config ) ; if ! config . append { rotation_state = rotate_output_file_to_idx ( rotation_state , config ) ? ; } NamingState :: IdxState ( rotation_state ) } } ; let ( log_file , created_at , p_path ) = open_log_file ( config , true ) ? ; let cleanup = rotate_config . cleanup ; let roll_state = match & rotate_config . criterion { Criterion :: Age ( age ) => RollState :: Age ( * age ) , Criterion :: Size ( size ) => { let written_bytes = if config . append { std :: fs :: metadata ( & p_path ) ? . len ( ) } else { 0 } ; RollState :: Size ( * size , written_bytes ) } // max_size, current_size } ; ( log_file , Some ( RotationState { naming_state , roll_state , created_at , cleanup , } ) , ) } } ; Ok ( FileLogWriterState { o_log_file : Some ( log_file ) , o_rotation_state , line_ending : if config . use_windows_line_ending { b" \r \n " } else { b" \n " } , } ) }
If rotate, the logger writes into a file with infix `_rCURRENT`.
If rotate the logger writes into a file with infix ` _rCURRENT ` .
config
&FileLogWriterConfig
o_rotation_config
&Option<RotationConfig>
config
&FileLogWriterConfig
o_rotation_config
&Option<RotationConfig>