Move logging config further into main (#840)

Don't swallow stdout if TUI is configured to run but only wallet is running
This commit is contained in:
Yeastplume 2018-03-21 20:48:56 +00:00 committed by Ignotus Peverell
parent 5a47a17101
commit fc01a33d15

View file

@ -84,48 +84,6 @@ fn start_server_tui(config: grin::ServerConfig) {
} }
fn main() { fn main() {
// First, load a global config object,
// then modify that object with any switches
// found so that the switches override the
// global config file
// This will return a global config object,
// which will either contain defaults for all // of the config structures or a
// configuration
// read from a config file
let mut global_config = GlobalConfig::new(None).unwrap_or_else(|e| {
panic!("Error parsing config file: {}", e);
});
if global_config.using_config_file {
// initialise the logger
let mut log_conf = global_config
.members
.as_mut()
.unwrap()
.logging
.clone()
.unwrap();
let run_tui = global_config.members.as_mut().unwrap().server.run_tui;
if run_tui.is_some() && run_tui.unwrap() {
log_conf.log_to_stdout = false;
log_conf.tui_running = Some(true);
}
init_logger(Some(log_conf));
global::set_mining_mode(
global_config
.members
.as_mut()
.unwrap()
.server
.clone()
.chain_type,
);
} else {
init_logger(Some(LoggingConfig::default()));
}
let args = App::new("Grin") let args = App::new("Grin")
.version("0.1") .version("0.1")
.author("The Grin Team") .author("The Grin Team")
@ -301,6 +259,48 @@ fn main() {
.get_matches(); .get_matches();
// load a global config object,
// then modify that object with any switches
// found so that the switches override the
// global config file
// This will return a global config object,
// which will either contain defaults for all // of the config structures or a
// configuration
// read from a config file
let mut global_config = GlobalConfig::new(None).unwrap_or_else(|e| {
panic!("Error parsing config file: {}", e);
});
if global_config.using_config_file {
// initialise the logger
let mut log_conf = global_config
.members
.as_mut()
.unwrap()
.logging
.clone()
.unwrap();
let run_tui = global_config.members.as_mut().unwrap().server.run_tui;
if run_tui.is_some() && run_tui.unwrap() && args.subcommand().0 != "wallet" {
log_conf.log_to_stdout = false;
log_conf.tui_running = Some(true);
}
init_logger(Some(log_conf));
global::set_mining_mode(
global_config
.members
.as_mut()
.unwrap()
.server
.clone()
.chain_type,
);
} else {
init_logger(Some(LoggingConfig::default()));
}
match args.subcommand() { match args.subcommand() {
// server commands and options // server commands and options
("server", Some(server_args)) => { ("server", Some(server_args)) => {