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:
committed by
Patrick Niklaus
parent
fb5bd818d9
commit
7323221e3b
+12
-3
@@ -68,6 +68,7 @@ static EngineConfig::Algorithm stringToAlgorithm(std::string algorithm)
|
||||
// generate boost::program_options object for the routing part
|
||||
inline unsigned generateServerProgramOptions(const int argc,
|
||||
const char *argv[],
|
||||
std::string verbosity,
|
||||
boost::filesystem::path &base_path,
|
||||
std::string &ip_address,
|
||||
int &ip_port,
|
||||
@@ -87,9 +88,12 @@ inline unsigned generateServerProgramOptions(const int argc,
|
||||
|
||||
// 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") //
|
||||
("trial", value<bool>(&trial)->implicit_value(true), "Quit after initialization");
|
||||
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())(
|
||||
"trial", value<bool>(&trial)->implicit_value(true), "Quit after initialization");
|
||||
|
||||
// declare a group of options that will be allowed on command line
|
||||
boost::program_options::options_description config_options("Configuration");
|
||||
@@ -202,10 +206,12 @@ int main(int argc, const char *argv[]) try
|
||||
int ip_port, requested_thread_num;
|
||||
|
||||
EngineConfig config;
|
||||
std::string verbosity;
|
||||
boost::filesystem::path base_path;
|
||||
std::string algorithm;
|
||||
const unsigned init_result = generateServerProgramOptions(argc,
|
||||
argv,
|
||||
verbosity,
|
||||
base_path,
|
||||
ip_address,
|
||||
ip_port,
|
||||
@@ -227,6 +233,9 @@ int main(int argc, const char *argv[]) try
|
||||
{
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
util::LogPolicy::GetInstance().SetLevel(verbosity);
|
||||
|
||||
if (!base_path.empty())
|
||||
{
|
||||
config.storage_config = storage::StorageConfig(base_path);
|
||||
|
||||
Reference in New Issue
Block a user