Improve log level selection from command line. Some extra shutdown logging.

This commit is contained in:
JoelKatz
2012-12-20 09:27:50 -08:00
parent ca25c6c3fb
commit 0106365098
4 changed files with 22 additions and 4 deletions

View File

@@ -57,6 +57,7 @@ extern int RpcDBCount, TxnDBCount, LedgerDBCount, WalletDBCount, HashNodeDBCount
void Application::stop() void Application::stop()
{ {
cLog(lsINFO) << "Received shutdown request";
mIOService.stop(); mIOService.stop();
mJobQueue.shutdown(); mJobQueue.shutdown();
mHashedObjectStore.bulkWrite(); mHashedObjectStore.bulkWrite();

View File

@@ -181,6 +181,7 @@ void JobQueue::shutdown()
mJobCond.notify_all(); mJobCond.notify_all();
while (mThreadCount != 0) while (mThreadCount != 0)
mJobCond.wait(sl); mJobCond.wait(sl);
cLog(lsDEBUG) << "Job queue has shut down";
} }
void JobQueue::setThreadCount(int c) void JobQueue::setThreadCount(int c)

View File

@@ -260,6 +260,7 @@ void ValidationCollection::flush()
{ {
bool anyNew = false; bool anyNew = false;
cLog(lsINFO) << "Flushing validations";
boost::mutex::scoped_lock sl(mValidationLock); boost::mutex::scoped_lock sl(mValidationLock);
BOOST_FOREACH(u160_val_pair& it, mCurrentValidations) BOOST_FOREACH(u160_val_pair& it, mCurrentValidations)
{ {
@@ -276,6 +277,7 @@ void ValidationCollection::flush()
boost::this_thread::sleep(boost::posix_time::milliseconds(100)); boost::this_thread::sleep(boost::posix_time::milliseconds(100));
sl.lock(); sl.lock();
} }
cLog(lsDEBUG) << "Validations flushed";
} }
void ValidationCollection::condWrite() void ValidationCollection::condWrite()

View File

@@ -90,7 +90,7 @@ int main(int argc, char* argv[])
// //
// Set up option parsing. // Set up option parsing.
// //
po::options_description desc("Options"); po::options_description desc("General Options");
desc.add_options() desc.add_options()
("help,h", "Display this message.") ("help,h", "Display this message.")
("conf", po::value<std::string>(), "Specify the configuration file.") ("conf", po::value<std::string>(), "Specify the configuration file.")
@@ -99,12 +99,21 @@ int main(int argc, char* argv[])
("test,t", "Perform unit tests.") ("test,t", "Perform unit tests.")
("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.")
("verbose,v", "Increase log level.") ("verbose,v", "Verbose logging.")
("load", "Load the current ledger from the local DB.") ("load", "Load the current ledger from the local DB.")
("start", "Start from a fresh Ledger.") ("start", "Start from a fresh Ledger.")
("net", "Get the initial ledger from the network.") ("net", "Get the initial ledger from the network.")
; ;
po::options_description hidden("Hidden Options");
hidden.add_options()
("trace,vvv", "Trace level logging")
("debug,vv", "Debug level logging")
;
po::options_description all("All Options");
all.add(desc).add(hidden);
// Interpret positional arguments as --parameters. // Interpret positional arguments as --parameters.
po::positional_options_description p; po::positional_options_description p;
p.add("parameters", -1); p.add("parameters", -1);
@@ -129,7 +138,7 @@ int main(int argc, char* argv[])
// Parse options, if no error. // Parse options, if no error.
try { try {
po::store(po::command_line_parser(argc, argv) po::store(po::command_line_parser(argc, argv)
.options(desc) // Parse options. .options(all) // Parse options.
.positional(p) // Remainder as --parameters. .positional(p) // Remainder as --parameters.
.run(), .run(),
vm); vm);
@@ -141,10 +150,15 @@ int main(int argc, char* argv[])
} }
} }
if (vm.count("verbose")) if (vm.count("trace"))
Log::setMinSeverity(lsTRACE, true); Log::setMinSeverity(lsTRACE, true);
else if (vm.count("debug"))
Log::setMinSeverity(lsDEBUG, true);
else if (vm.count("verbose"))
Log::setMinSeverity(lsINFO, true);
else else
Log::setMinSeverity(lsWARNING, true); Log::setMinSeverity(lsWARNING, true);
InstanceType::multiThread(); InstanceType::multiThread();
if (vm.count("test")) if (vm.count("test"))