Refactor logging, improve error handling workflow, clang-format. (#3385)

This commit is contained in:
Daniel Patterson
2016-12-06 12:30:46 -08:00
committed by GitHub
parent 6f4c6e84ae
commit 468d8c0031
62 changed files with 1778 additions and 1607 deletions
+13 -14
View File
@@ -1,7 +1,7 @@
#include "extractor/extractor.hpp"
#include "extractor/extractor_config.hpp"
#include "extractor/scripting_environment_lua.hpp"
#include "util/simple_logger.hpp"
#include "util/log.hpp"
#include "util/version.hpp"
#include <tbb/task_scheduler_init.h>
@@ -84,19 +84,19 @@ return_code parseArguments(int argc, char *argv[], extractor::ExtractorConfig &e
}
catch (const boost::program_options::error &e)
{
util::SimpleLogger().Write(logWARNING) << "[error] " << e.what();
util::Log(logERROR) << e.what();
return return_code::fail;
}
if (option_variables.count("version"))
{
util::SimpleLogger().Write() << OSRM_VERSION;
std::cout << OSRM_VERSION << std::endl;
return return_code::exit;
}
if (option_variables.count("help"))
{
util::SimpleLogger().Write() << visible_options;
std::cout << visible_options;
return return_code::exit;
}
@@ -104,7 +104,7 @@ return_code parseArguments(int argc, char *argv[], extractor::ExtractorConfig &e
if (!option_variables.count("input"))
{
util::SimpleLogger().Write() << visible_options;
std::cout << visible_options;
return return_code::exit;
}
@@ -132,21 +132,21 @@ int main(int argc, char *argv[]) try
if (1 > extractor_config.requested_num_threads)
{
util::SimpleLogger().Write(logWARNING) << "Number of threads must be 1 or larger";
util::Log(logERROR) << "Number of threads must be 1 or larger";
return EXIT_FAILURE;
}
if (!boost::filesystem::is_regular_file(extractor_config.input_path))
{
util::SimpleLogger().Write(logWARNING)
<< "Input file " << extractor_config.input_path.string() << " not found!";
util::Log(logERROR) << "Input file " << extractor_config.input_path.string()
<< " not found!";
return EXIT_FAILURE;
}
if (!boost::filesystem::is_regular_file(extractor_config.profile_path))
{
util::SimpleLogger().Write(logWARNING)
<< "Profile " << extractor_config.profile_path.string() << " not found!";
util::Log(logERROR) << "Profile " << extractor_config.profile_path.string()
<< " not found!";
return EXIT_FAILURE;
}
@@ -157,8 +157,7 @@ int main(int argc, char *argv[]) try
}
catch (const std::bad_alloc &e)
{
util::SimpleLogger().Write(logWARNING) << "[exception] " << e.what();
util::SimpleLogger().Write(logWARNING)
<< "Please provide more memory or consider using a larger swapfile";
util::Log(logERROR) << "[exception] " << e.what();
util::Log(logERROR) << "Please provide more memory or consider using a larger swapfile";
return EXIT_FAILURE;
}
}