pub fn redirect_stderr_to_file(logfile: Option<String>) -> Option<JoinHandle<()>> {
    // Default to RUST_BACKTRACE=1 for more informative validator logs
    if env::var_os("RUST_BACKTRACE").is_none() {
        env::set_var("RUST_BACKTRACE", "1")
    }

    let filter = "solana=info";
    match logfile {
        None => {
            solana_logger::setup_with_default(filter);
            None
        }
        Some(logfile) => {
            #[cfg(unix)]
            {
                use log::info;
                let mut signals =
                    signal_hook::iterator::Signals::new(&[signal_hook::consts::SIGUSR1])
                        .unwrap_or_else(|err| {
                            eprintln!("Unable to register SIGUSR1 handler: {:?}", err);
                            exit(1);
                        });

                solana_logger::setup_with_default(filter);
                redirect_stderr(&logfile);
                Some(std::thread::spawn(move || {
                    for signal in signals.forever() {
                        info!(
                            "received SIGUSR1 ({}), reopening log file: {:?}",
                            signal, logfile
                        );
                        redirect_stderr(&logfile);
                    }
                }))
            }
            #[cfg(not(unix))]
            {
                println!("logrotate is not supported on this platform");
                solana_logger::setup_file_with_default(&logfile, filter);
                None
            }
        }
    }
}
// Redirect stderr to a file with support for logrotate by sending a SIGUSR1 to the process.
//
// Upon success, future `log` macros and `eprintln!()` can be found in the specified log file.
Redirect stderr to a file with support for logrotate by sending a SIGUSR1 to the process.
Upon success, future `log` macros and `eprintln!()` can be found in the specified log file.
Redirect stderr to a file with support for logrotate by sending a SIGUSR1 to the process . Upon success future ` log ` macros and ` eprintln! () ` can be found in the specified log file .
pub fn redirect_stderr_to_file(logfile: Option<String>) -> Option<JoinHandle<()>> {
    // Default to RUST_BACKTRACE=1 for more informative validator logs
    if env::var_os("RUST_BACKTRACE").is_none() {
        env::set_var("RUST_BACKTRACE", "1")
    }
    let filter = "solana=info";
    match logfile {
        None => {
            solana_logger::setup_with_default(filter);
            None
        }
        Some(logfile) => {
            #[cfg(unix)]
            {
                use log::info;
                let mut signals =
                    signal_hook::iterator::Signals::new(&[signal_hook::consts::SIGUSR1])
                        .unwrap_or_else(|err| {
                            eprintln!("Unable to register SIGUSR1 handler: {:?}", err);
                            exit(1);
                        });
                solana_logger::setup_with_default(filter);
                redirect_stderr(&logfile);
                Some(std::thread::spawn(move || {
                    for signal in signals.forever() {
                        info!(
                            "received SIGUSR1 ({}), reopening log file: {:?}",
                            signal, logfile
                        );
                        redirect_stderr(&logfile);
                    }
                }))
            }
            #[cfg(not(unix))]
            {
                println!("logrotate is not supported on this platform");
                solana_logger::setup_file_with_default(&logfile, filter);
                None
            }
        }
    }
}
pub fn redirect_stderr_to_file ( logfile : Option < String > ) -> Option < JoinHandle < ( ) > > { // Default to RUST_BACKTRACE=1 for more informative validator logs if env :: var_os ( " " ) . is_none ( ) { env :: set_var ( " " , " " ) } let filter = " " ; match logfile { None => { solana_logger :: setup_with_default ( filter ) ; None } Some ( logfile ) => { # [ cfg ( unix ) ] { use log :: info ; let mut signals = signal_hook :: iterator :: Signals :: new ( & [ signal_hook :: consts :: SIGUSR1 ] ) . unwrap_or_else ( | err | { eprintln ! ( " " err ) ; exit ( 1 ) ; } ) ; solana_logger :: setup_with_default ( filter ) ; redirect_stderr ( & logfile ) ; Some ( std :: thread :: spawn ( move | | { for signal in signals . forever ( ) { info ! ( " " signal logfile ) ; redirect_stderr ( & logfile ) ; } } ) ) } # [ cfg ( not ( unix ) ) ] { println ! ( " " ) ; solana_logger :: setup_file_with_default ( & logfile , filter ) ; None } } } }
Redirect stderr to a file with support for logrotate by sending a SIGUSR1 to the process.
Redirect stderr to a file with support for logrotate by sending a SIGUSR1 to the process .
logfile
Option<String>