Add --verbosity,-l command line option

Allow to fine-control logging verbosity via command line
and LogPolicy setting (useful when OSRM used as library).

Closes #4299
This commit is contained in:
Mateusz Loskot
2017-08-28 21:20:13 +02:00
committed by Patrick Niklaus
parent fb5bd818d9
commit 7323221e3b
13 changed files with 144 additions and 38 deletions
+9 -1
View File
@@ -52,12 +52,16 @@ void springClean()
// generate boost::program_options object for the routing part
bool generateDataStoreOptions(const int argc,
const char *argv[],
std::string &verbosity,
boost::filesystem::path &base_path,
int &max_wait)
{
// declare a group of options that will be allowed only on command line
boost::program_options::options_description generic_options("Options");
generic_options.add_options()("version,v", "Show version")("help,h", "Show this help message")(
"verbosity,l",
boost::program_options::value<std::string>(&verbosity)->default_value("INFO"),
std::string("Log verbosity level: " + util::LogPolicy::GetLevels()).c_str())(
"remove-locks,r", "Remove locks")("spring-clean,s",
"Spring-cleaning all shared memory regions");
@@ -157,12 +161,16 @@ int main(const int argc, const char *argv[]) try
util::LogPolicy::GetInstance().Unmute();
std::string verbosity;
boost::filesystem::path base_path;
int max_wait = -1;
if (!generateDataStoreOptions(argc, argv, base_path, max_wait))
if (!generateDataStoreOptions(argc, argv, verbosity, base_path, max_wait))
{
return EXIT_SUCCESS;
}
util::LogPolicy::GetInstance().SetLevel(verbosity);
storage::StorageConfig config(base_path);
if (!config.IsValid())
{