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
-4
@@ -28,11 +28,17 @@ enum class return_code : unsigned
|
||||
exit
|
||||
};
|
||||
|
||||
return_code parseArguments(int argc, char *argv[], contractor::ContractorConfig &contractor_config)
|
||||
return_code parseArguments(int argc,
|
||||
char *argv[],
|
||||
std::string &verbosity,
|
||||
contractor::ContractorConfig &contractor_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 on command line
|
||||
boost::program_options::options_description config_options("Configuration");
|
||||
@@ -137,11 +143,11 @@ return_code parseArguments(int argc, char *argv[], contractor::ContractorConfig
|
||||
|
||||
int main(int argc, char *argv[]) try
|
||||
{
|
||||
|
||||
util::LogPolicy::GetInstance().Unmute();
|
||||
std::string verbosity;
|
||||
contractor::ContractorConfig contractor_config;
|
||||
|
||||
const return_code result = parseArguments(argc, argv, contractor_config);
|
||||
const return_code result = parseArguments(argc, argv, verbosity, contractor_config);
|
||||
|
||||
if (return_code::fail == result)
|
||||
{
|
||||
@@ -153,6 +159,8 @@ int main(int argc, char *argv[]) try
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
util::LogPolicy::GetInstance().SetLevel(verbosity);
|
||||
|
||||
contractor_config.UseDefaultOutputNames(contractor_config.base_path);
|
||||
|
||||
if (1 > contractor_config.requested_num_threads)
|
||||
|
||||
+12
-4
@@ -21,12 +21,17 @@ enum class return_code : unsigned
|
||||
exit
|
||||
};
|
||||
|
||||
return_code
|
||||
parseArguments(int argc, char *argv[], customizer::CustomizationConfig &customization_config)
|
||||
return_code parseArguments(int argc,
|
||||
char *argv[],
|
||||
std::string &verbosity,
|
||||
customizer::CustomizationConfig &customization_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");
|
||||
@@ -130,9 +135,10 @@ parseArguments(int argc, char *argv[], customizer::CustomizationConfig &customiz
|
||||
int main(int argc, char *argv[]) try
|
||||
{
|
||||
util::LogPolicy::GetInstance().Unmute();
|
||||
std::string verbosity;
|
||||
customizer::CustomizationConfig customization_config;
|
||||
|
||||
const auto result = parseArguments(argc, argv, customization_config);
|
||||
const auto result = parseArguments(argc, argv, verbosity, customization_config);
|
||||
|
||||
if (return_code::fail == result)
|
||||
{
|
||||
@@ -144,6 +150,8 @@ int main(int argc, char *argv[]) try
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
util::LogPolicy::GetInstance().SetLevel(verbosity);
|
||||
|
||||
// set the default in/output names
|
||||
customization_config.UseDefaultOutputNames(customization_config.base_path);
|
||||
|
||||
|
||||
+13
-4
@@ -24,11 +24,17 @@ enum class return_code : unsigned
|
||||
exit
|
||||
};
|
||||
|
||||
return_code parseArguments(int argc, char *argv[], extractor::ExtractorConfig &extractor_config)
|
||||
return_code parseArguments(int argc,
|
||||
char *argv[],
|
||||
std::string &verbosity,
|
||||
extractor::ExtractorConfig &extractor_config)
|
||||
{
|
||||
// declare a group of options that will be allowed only on command line
|
||||
// declare a group of options that will be a llowed 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");
|
||||
@@ -127,8 +133,9 @@ int main(int argc, char *argv[]) try
|
||||
{
|
||||
util::LogPolicy::GetInstance().Unmute();
|
||||
extractor::ExtractorConfig extractor_config;
|
||||
std::string verbosity;
|
||||
|
||||
const auto result = parseArguments(argc, argv, extractor_config);
|
||||
const auto result = parseArguments(argc, argv, verbosity, extractor_config);
|
||||
|
||||
if (return_code::fail == result)
|
||||
{
|
||||
@@ -140,6 +147,8 @@ int main(int argc, char *argv[]) try
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
util::LogPolicy::GetInstance().SetLevel(verbosity);
|
||||
|
||||
extractor_config.UseDefaultOutputNames(extractor_config.input_path);
|
||||
|
||||
if (1 > extractor_config.requested_num_threads)
|
||||
|
||||
+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);
|
||||
|
||||
|
||||
+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);
|
||||
|
||||
+9
-1
@@ -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())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user