From 7e17ea8705f1a4b343b7e1a6b7d8f034f48f654c Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Wed, 6 Nov 2019 16:08:49 -0700 Subject: [PATCH] Fix windows build (#6774) (#6780) (cherry picked from commit 2491719f36f696a65f4b50b8c2cceeb7fd694cdb) --- validator/src/main.rs | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/validator/src/main.rs b/validator/src/main.rs index 55d1d18906..0e11c6cc87 100644 --- a/validator/src/main.rs +++ b/validator/src/main.rs @@ -533,30 +533,32 @@ pub fn main() { option_env!("CI_COMMIT").unwrap_or("unknown") ); - let default_logfile = format!( - "solana-validator-{}-{}.log", - identity_keypair.pubkey(), - chrono::Local::now().to_rfc3339() - ); - let logfile = matches.value_of("logfile").unwrap_or(&default_logfile); - - let _log_redirect = if logfile == "-" { - None - } else { + let _log_redirect = { #[cfg(unix)] { - println!("log file: {}", logfile); - Some(gag::Redirect::stderr(File::create(logfile).unwrap_or_else( - |err| { - eprintln!("Unable to create {}: {:?}", logfile, err); - exit(1); - }, - ))) + let default_logfile = format!( + "solana-validator-{}-{}.log", + identity_keypair.pubkey(), + chrono::Local::now().to_rfc3339() + ); + let logfile = matches.value_of("logfile").unwrap_or(&default_logfile); + + if logfile == "-" { + None + } else { + println!("log file: {}", logfile); + Some(gag::Redirect::stderr(File::create(logfile).unwrap_or_else( + |err| { + eprintln!("Unable to create {}: {:?}", logfile, err); + exit(1); + }, + ))) + } } #[cfg(not(unix))] { println!("logging to a file is not supported on this platform"); - None + () } };