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
+10
-3
@@ -69,11 +69,15 @@ void validate(boost::any &v, const std::vector<std::string> &values, MaxCellSize
|
||||
v = boost::any(MaxCellSizesArgument{output});
|
||||
}
|
||||
|
||||
return_code parseArguments(int argc, char *argv[], partition::PartitionConfig &config)
|
||||
return_code
|
||||
parseArguments(int argc, char *argv[], std::string &verbosity, partition::PartitionConfig &config)
|
||||
{
|
||||
// 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");
|
||||
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());
|
||||
|
||||
// declare a group of options that will be allowed both on command line
|
||||
boost::program_options::options_description config_options("Configuration");
|
||||
@@ -184,9 +188,10 @@ return_code parseArguments(int argc, char *argv[], partition::PartitionConfig &c
|
||||
int main(int argc, char *argv[]) try
|
||||
{
|
||||
util::LogPolicy::GetInstance().Unmute();
|
||||
std::string verbosity;
|
||||
partition::PartitionConfig partition_config;
|
||||
|
||||
const auto result = parseArguments(argc, argv, partition_config);
|
||||
const auto result = parseArguments(argc, argv, verbosity, partition_config);
|
||||
|
||||
if (return_code::fail == result)
|
||||
{
|
||||
@@ -198,6 +203,8 @@ int main(int argc, char *argv[]) try
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
util::LogPolicy::GetInstance().SetLevel(verbosity);
|
||||
|
||||
// set the default in/output names
|
||||
partition_config.UseDefaultOutputNames(partition_config.base_path);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user