|
@@ -35,10 +35,12 @@ undefined reference to `void boost::log::v2_mt_posix::init_from_stream
|
|
|
https://github.com/boostorg/log/issues/46
|
|
|
*/
|
|
|
|
|
|
+/*
|
|
|
BOOST_LOG_ATTRIBUTE_KEYWORD(scope, "Scope",
|
|
|
boost::log::attributes::named_scope::value_type)
|
|
|
+*/
|
|
|
|
|
|
-void init_logging(void) {
|
|
|
+void init_logging(int logging_level) {
|
|
|
// because TimeStamp is missing by default.
|
|
|
boost::log::add_common_attributes();
|
|
|
|
|
@@ -60,6 +62,7 @@ void init_logging(void) {
|
|
|
boost::log::keywords::format =
|
|
|
(boost::log::expressions::stream
|
|
|
<< boost::log::expressions::format_date_time<
|
|
|
+ // boost::posix_time::ptime>("TimeStamp", "%I:%M:%S.%f %p")
|
|
|
boost::posix_time::ptime>("TimeStamp", "%H:%M:%S.%f")
|
|
|
<< " " << std::setw(8) << boost::log::trivial::severity
|
|
|
<< " "
|
|
@@ -71,12 +74,17 @@ void init_logging(void) {
|
|
|
auto core = boost::log::core::get();
|
|
|
// boost::log::core::get()->set_filter(boost::log::trivial::severity >=
|
|
|
// boost::log::trivial::info);
|
|
|
- core->set_filter(boost::log::trivial::severity >= boost::log::trivial::info);
|
|
|
+
|
|
|
+ // core->set_filter(boost::log::trivial::severity >=
|
|
|
+ // boost::log::trivial::info);
|
|
|
+ core->set_filter(boost::log::trivial::severity >= logging_level);
|
|
|
+
|
|
|
// core->add_global_attribute("Scopes", boost::log::keywords::format = "%n
|
|
|
// (%f:%l)"); core->set_formatter("Scopes", boost::log::keywords::format = "%n
|
|
|
// (%f:%l)"); logging::core::get()->add_global_attribute("Scopes",
|
|
|
// attributes::named_scope());
|
|
|
- core->add_global_attribute("Scope", boost::log::attributes::named_scope());
|
|
|
+
|
|
|
+ // core->add_global_attribute("Scope", boost::log::attributes::named_scope());
|
|
|
}
|
|
|
|
|
|
int main(int argc, char *argv[]) {
|
|
@@ -87,11 +95,16 @@ int main(int argc, char *argv[]) {
|
|
|
return EXIT_FAILURE;
|
|
|
}
|
|
|
|
|
|
- init_logging();
|
|
|
- BOOST_LOG_NAMED_SCOPE("main");
|
|
|
-
|
|
|
std::map<std::string, std::string> config = yaml_parse(argv[1]);
|
|
|
|
|
|
+ auto value = config.find("log_level");
|
|
|
+ int log_level = 3;
|
|
|
+ if (value != config.end()) {
|
|
|
+ log_level = std::stoi( value->second ); // config[value]);
|
|
|
+ }
|
|
|
+
|
|
|
+ init_logging(log_level);
|
|
|
+
|
|
|
/*
|
|
|
try {
|
|
|
// Parse the file as JSON
|