diff --git a/src/cpp/ripple/Config.cpp b/src/cpp/ripple/Config.cpp index 4701634fb..03c545332 100644 --- a/src/cpp/ripple/Config.cpp +++ b/src/cpp/ripple/Config.cpp @@ -1,3 +1,6 @@ +// +// TODO: Check permissions on config file before using it. +// #include "Config.h" #include "utils.h" @@ -48,7 +51,7 @@ Config theConfig; -void Config::setup(const std::string& strConf) +void Config::setup(const std::string& strConf, bool bQuiet) { boost::system::error_code ec; @@ -58,6 +61,8 @@ void Config::setup(const std::string& strConf) // that with "db" as the data directory. // + QUIET = bQuiet; + if (!strConf.empty()) { // --conf= : everything is relative that file. @@ -172,7 +177,8 @@ void Config::setup(const std::string& strConf) void Config::load() { - std::cout << "Loading: " << CONFIG_FILE << std::endl; + if (!QUIET) + std::cerr << "Loading: " << CONFIG_FILE << std::endl; std::ifstream ifsConfig(CONFIG_FILE.c_str(), std::ios::in); diff --git a/src/cpp/ripple/Config.h b/src/cpp/ripple/Config.h index 9704396f7..b7e4898c0 100644 --- a/src/cpp/ripple/Config.h +++ b/src/cpp/ripple/Config.h @@ -46,6 +46,8 @@ class Config { public: // Configuration parameters + bool QUIET; + boost::filesystem::path CONFIG_FILE; boost::filesystem::path CONFIG_DIR; boost::filesystem::path DATA_DIR; @@ -113,7 +115,7 @@ public: // Client behavior int ACCOUNT_PROBE_MAX; // How far to scan for accounts. - void setup(const std::string& strConf); + void setup(const std::string& strConf, bool bQuiet); void load(); }; diff --git a/src/cpp/ripple/main.cpp b/src/cpp/ripple/main.cpp index 360c07857..6449079d2 100644 --- a/src/cpp/ripple/main.cpp +++ b/src/cpp/ripple/main.cpp @@ -33,51 +33,51 @@ bool init_unit_test() void printHelp(const po::options_description& desc) { - cout << SYSTEM_NAME "d [options] " << endl; + cerr << SYSTEM_NAME "d [options] " << endl; - cout << desc << endl; + cerr << desc << endl; - cout << "Commands: " << endl; - cout << " account_domain_set []" << endl; - cout << " account_email_set []" << endl; - cout << " account_info |" << endl; - cout << " account_info || []" << endl; - cout << " account_message_set " << endl; - cout << " account_publish_set " << endl; - cout << " account_rate_set " << endl; - cout << " account_wallet_set []" << endl; - cout << " connect []" << endl; - cout << " data_delete " << endl; - cout << " data_fetch " << endl; - cout << " data_store " << endl; - cout << " ledger [|current|lastclosed] [full]" << endl; - cout << " logrotate " << endl; - cout << " nickname_info " << endl; - cout << " nickname_set [] []" << endl; - cout << " offer_create [passive]" << endl; - cout << " offer_cancel " << endl; - cout << " password_fund []" << endl; - cout << " password_set []" << endl; - cout << " peers" << endl; - cout << " ripple ..." << endl; - cout << " ripple_lines_get || []" << endl; - cout << " ripple_line_set [] []" << endl; - cout << " send [] [] []" << endl; - cout << " stop" << endl; - cout << " tx " << endl; - cout << " unl_add | []" << endl; - cout << " unl_delete |" << endl; - cout << " unl_list" << endl; - cout << " unl_load" << endl; - cout << " unl_network" << endl; - cout << " unl_reset" << endl; - cout << " validation_create [||]" << endl; - cout << " validation_seed [||]" << endl; - cout << " wallet_add [] []" << endl; - cout << " wallet_accounts " << endl; - cout << " wallet_claim [] []" << endl; - cout << " wallet_seed [||]" << endl; - cout << " wallet_propose []" << endl; + cerr << "Commands: " << endl; + cerr << " account_domain_set []" << endl; + cerr << " account_email_set []" << endl; + cerr << " account_info |" << endl; + cerr << " account_info || []" << endl; + cerr << " account_message_set " << endl; + cerr << " account_publish_set " << endl; + cerr << " account_rate_set " << endl; + cerr << " account_wallet_set []" << endl; + cerr << " connect []" << endl; + cerr << " data_delete " << endl; + cerr << " data_fetch " << endl; + cerr << " data_store " << endl; + cerr << " ledger [|current|lastclosed] [full]" << endl; + cerr << " logrotate " << endl; + cerr << " nickname_info " << endl; + cerr << " nickname_set [] []" << endl; + cerr << " offer_create [passive]" << endl; + cerr << " offer_cancel " << endl; + cerr << " password_fund []" << endl; + cerr << " password_set []" << endl; + cerr << " peers" << endl; + cerr << " ripple ..." << endl; + cerr << " ripple_lines_get || []" << endl; + cerr << " ripple_line_set [] []" << endl; + cerr << " send [] [] []" << endl; + cerr << " stop" << endl; + cerr << " tx " << endl; + cerr << " unl_add | []" << endl; + cerr << " unl_delete |" << endl; + cerr << " unl_list" << endl; + cerr << " unl_load" << endl; + cerr << " unl_network" << endl; + cerr << " unl_reset" << endl; + cerr << " validation_create [||]" << endl; + cerr << " validation_seed [||]" << endl; + cerr << " wallet_add [] []" << endl; + cerr << " wallet_accounts " << endl; + cerr << " wallet_claim [] []" << endl; + cerr << " wallet_seed [||]" << endl; + cerr << " wallet_propose []" << endl; } int main(int argc, char* argv[]) @@ -96,6 +96,7 @@ int main(int argc, char* argv[]) ("standalone,a", "Run with no peers.") ("test,t", "Perform unit tests.") ("parameters", po::value< vector >(), "Specify comma separated parameters.") + ("quiet,q", "Reduce diagnotics.") ("verbose,v", "Increase log level.") ("load", "Load the current ledger from the local DB.") ("start", "Start from a fresh Ledger.") @@ -138,7 +139,6 @@ int main(int argc, char* argv[]) } } - if (vm.count("verbose")) Log::setMinSeverity(lsTRACE, true); else @@ -152,7 +152,9 @@ int main(int argc, char* argv[]) if (!iResult) { - theConfig.setup(vm.count("conf") ? vm["conf"].as() : ""); + theConfig.setup( + vm.count("conf") ? vm["conf"].as() : "", // Config file. + !!vm.count("quiet")); // Quiet flag. if (vm.count("standalone")) {