Command line option to not log to console after startup

This commit is contained in:
Mark Travis
2015-12-10 07:51:01 -08:00
committed by Nik Bougalis
parent d17c8e235f
commit f26835e507
5 changed files with 22 additions and 2 deletions

View File

@@ -926,6 +926,8 @@ void ApplicationImp::setup()
logs_->severity (beast::Journal::kDebug); logs_->severity (beast::Journal::kDebug);
} }
logs_->silent (config_->SILENT);
if (!config_->RUN_STANDALONE) if (!config_->RUN_STANDALONE)
timeKeeper_->run(config_->SNTP_SERVERS); timeKeeper_->run(config_->SNTP_SERVERS);

View File

@@ -271,6 +271,7 @@ int run (int argc, char** argv)
("parameters", po::value< vector<string> > (), "Specify comma separated parameters.") ("parameters", po::value< vector<string> > (), "Specify comma separated parameters.")
("quiet,q", "Reduce diagnotics.") ("quiet,q", "Reduce diagnotics.")
("quorum", po::value <int> (), "Set the validation quorum.") ("quorum", po::value <int> (), "Set the validation quorum.")
("silent", "No output to the console after startup.")
("verbose,v", "Verbose logging.") ("verbose,v", "Verbose logging.")
("load", "Load the current ledger from the local DB.") ("load", "Load the current ledger from the local DB.")
("valid", "Consider the initial ledger a valid network ledger.") ("valid", "Consider the initial ledger a valid network ledger.")
@@ -355,6 +356,9 @@ int run (int argc, char** argv)
// config file, quiet flag. // config file, quiet flag.
config->setup (configFile, bool (vm.count ("quiet"))); config->setup (configFile, bool (vm.count ("quiet")));
if (vm.count ("silent"))
config->SILENT = true;
if (vm.count ("standalone")) if (vm.count ("standalone"))
{ {
config->RUN_STANDALONE = true; config->RUN_STANDALONE = true;

View File

@@ -148,6 +148,7 @@ private:
std::map <std::string, Sink, beast::ci_less> sinks_; std::map <std::string, Sink, beast::ci_less> sinks_;
beast::Journal::Severity level_; beast::Journal::Severity level_;
File file_; File file_;
bool silent_ = false;
public: public:
Logs(); Logs();
@@ -183,6 +184,17 @@ public:
std::string std::string
rotate(); rotate();
/**
* Set flag to write logs to stderr (false) or not (true).
*
* @param bSilent Set flag accordingly.
*/
void
silent (bool bSilent)
{
silent_ = bSilent;
}
public: public:
static static
LogSeverity LogSeverity

View File

@@ -176,7 +176,8 @@ Logs::write (beast::Journal::Severity level, std::string const& partition,
format (s, text, level, partition); format (s, text, level, partition);
std::lock_guard <std::mutex> lock (mutex_); std::lock_guard <std::mutex> lock (mutex_);
file_.writeln (s); file_.writeln (s);
std::cerr << s << '\n'; if (! silent_)
std::cerr << s << '\n';
// VFALCO TODO Fix console output // VFALCO TODO Fix console output
//if (console) //if (console)
// out_.write_console(s); // out_.write_console(s);

View File

@@ -160,7 +160,8 @@ public:
beast::File getModuleDatabasePath () const; beast::File getModuleDatabasePath () const;
bool doImport = false; bool doImport = false;
bool QUIET = false; bool QUIET = false; // Minimize logging verbosity.
bool SILENT = false; // No output to console after startup.
bool ELB_SUPPORT = false; bool ELB_SUPPORT = false;
std::string VALIDATORS_SITE; // Where to find validators.txt on the Internet. std::string VALIDATORS_SITE; // Where to find validators.txt on the Internet.