mirror of
https://github.com/mimblewimble/grin.git
synced 2025-01-21 11:31:08 +03:00
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:
parent
5a47a17101
commit
fc01a33d15
1 changed files with 42 additions and 42 deletions
|
@ -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)) => {
|
||||||
|
|
Loading…
Reference in a new issue