wallet: fix --log-file not working

This commit is contained in:
moneromooo-monero 2017-02-26 22:59:46 +00:00
parent beee286c7b
commit b8a08f199a
No known key found for this signature in database
GPG key ID: 686F07454D6CEFC3
4 changed files with 30 additions and 29 deletions

View file

@ -4333,7 +4333,8 @@ int main(int argc, char* argv[])
argc, argv, argc, argv,
"monero-wallet-cli [--wallet-file=<file>|--generate-new-wallet=<file>] [<COMMAND>]", "monero-wallet-cli [--wallet-file=<file>|--generate-new-wallet=<file>] [<COMMAND>]",
desc_params, desc_params,
positional_options positional_options,
"monero-wallet-cli.log"
); );
if (!vm) if (!vm)

View file

@ -73,6 +73,7 @@ namespace wallet_args
const char* const usage, const char* const usage,
boost::program_options::options_description desc_params, boost::program_options::options_description desc_params,
const boost::program_options::positional_options_description& positional_options, const boost::program_options::positional_options_description& positional_options,
const char *default_log_name,
bool log_to_console) bool log_to_console)
{ {
@ -106,17 +107,23 @@ namespace wallet_args
po::options_description desc_all; po::options_description desc_all;
desc_all.add(desc_general).add(desc_params); desc_all.add(desc_general).add(desc_params);
po::variables_map vm; po::variables_map vm;
std::string log_path;
bool r = command_line::handle_error_helper(desc_all, [&]() bool r = command_line::handle_error_helper(desc_all, [&]()
{ {
po::store(command_line::parse_command_line(argc, argv, desc_general, true), vm); auto parser = po::command_line_parser(argc, argv).options(desc_all).positional(positional_options);
po::store(parser.run(), vm);
po::notify(vm);
return true;
});
if (!r)
return boost::none;
if (command_line::has_arg(vm, arg_log_file)) std::string log_path;
if (!vm["log-file"].defaulted())
log_path = command_line::get_arg(vm, arg_log_file); log_path = command_line::get_arg(vm, arg_log_file);
else else
log_path = mlog_get_default_log_path("monero-wallet-cli.log"); log_path = mlog_get_default_log_path(default_log_name);
mlog_configure(log_path, log_to_console); mlog_configure(log_path, log_to_console);
if (command_line::has_arg(vm, arg_log_level)) if (!vm["log-level"].defaulted())
{ {
mlog_set_log(command_line::get_arg(vm, arg_log_level).c_str()); mlog_set_log(command_line::get_arg(vm, arg_log_level).c_str());
} }
@ -126,21 +133,13 @@ namespace wallet_args
tools::msg_writer() << "Monero '" << MONERO_RELEASE_NAME << "' (v" << MONERO_VERSION_FULL << ")"; tools::msg_writer() << "Monero '" << MONERO_RELEASE_NAME << "' (v" << MONERO_VERSION_FULL << ")";
tools::msg_writer() << wallet_args::tr("Usage:") << ' ' << usage; tools::msg_writer() << wallet_args::tr("Usage:") << ' ' << usage;
tools::msg_writer() << desc_all; tools::msg_writer() << desc_all;
return false; return boost::none;
} }
else if (command_line::get_arg(vm, command_line::arg_version)) else if (command_line::get_arg(vm, command_line::arg_version))
{ {
tools::msg_writer() << "Monero '" << MONERO_RELEASE_NAME << "' (v" << MONERO_VERSION_FULL << ")"; tools::msg_writer() << "Monero '" << MONERO_RELEASE_NAME << "' (v" << MONERO_VERSION_FULL << ")";
return false;
}
auto parser = po::command_line_parser(argc, argv).options(desc_params).positional(positional_options);
po::store(parser.run(), vm);
po::notify(vm);
return true;
});
if (!r)
return boost::none; return boost::none;
}
if(command_line::has_arg(vm, arg_max_concurrency)) if(command_line::has_arg(vm, arg_max_concurrency))
tools::set_max_concurrency(command_line::get_arg(vm, arg_max_concurrency)); tools::set_max_concurrency(command_line::get_arg(vm, arg_max_concurrency));

View file

@ -50,5 +50,5 @@ namespace wallet_args
const char* const usage, const char* const usage,
boost::program_options::options_description desc_params, boost::program_options::options_description desc_params,
const boost::program_options::positional_options_description& positional_options, const boost::program_options::positional_options_description& positional_options,
bool log_to_console = false); const char *default_log_name, bool log_to_console = false);
} }

View file

@ -1397,6 +1397,7 @@ int main(int argc, char** argv) {
"monero-wallet-rpc [--wallet-file=<file>|--generate-from-json=<file>] [--rpc-bind-port=<port>]", "monero-wallet-rpc [--wallet-file=<file>|--generate-from-json=<file>] [--rpc-bind-port=<port>]",
desc_params, desc_params,
po::positional_options_description(), po::positional_options_description(),
"monero-wallet-rpc.log",
true true
); );
if (!vm) if (!vm)