Sfoglia il codice sorgente

date_time does not help boost. Set logging level.

Steve Thielemann 3 anni fa
parent
commit
3e6d267e89
1 ha cambiato i file con 28 aggiunte e 20 eliminazioni
  1. 28 20
      twproxy.cpp

+ 28 - 20
twproxy.cpp

@@ -40,7 +40,7 @@ BOOST_LOG_ATTRIBUTE_KEYWORD(scope, "Scope",
                             boost::log::attributes::named_scope::value_type)
 */
 
-void init_logging(int logging_level) {
+void init_logging(void) {
   // because TimeStamp is missing by default.
   boost::log::add_common_attributes();
 
@@ -62,29 +62,32 @@ void init_logging(int logging_level) {
       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
-           << " "
-           // << fmtScope << " : "
+                  boost::posix_time::ptime>("TimeStamp", "%H:%M:%S.%f %I:%M %p")
+           // boost::posix_time::ptime>("TimeStamp", "%H:%M:%S.%f")
+           << " " << std::setw(8) << boost::log::trivial::severity << " "
            << boost::log::expressions::smessage)
 
   );
 
-  auto core = boost::log::core::get();
-  // boost::log::core::get()->set_filter(boost::log::trivial::severity >=
-  //                                     boost::log::trivial::info);
+  /*
+    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 >= logging_level);
+    // core->set_filter(boost::log::trivial::severity >=
+    // boost::log::trivial::info);
 
-  // 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->set_filter(boost::log::trivial::severity >= logging_level);
 
-  // core->add_global_attribute("Scope", boost::log::attributes::named_scope());
+    // 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());
+  */
 }
 
 int main(int argc, char *argv[]) {
@@ -98,12 +101,17 @@ int main(int argc, char *argv[]) {
   std::map<std::string, std::string> config = yaml_parse(argv[1]);
 
   auto value = config.find("log_level");
-  int log_level = 3;
+  int log_level = 2;
   if (value != config.end()) {
-    log_level = std::stoi( value->second ); // config[value]);
+    log_level = std::stoi(value->second); // config[value]);
   }
 
-  init_logging(log_level);
+  init_logging();
+
+  auto core = boost::log::core::get();
+  core->set_filter(boost::log::trivial::severity >= log_level);
+
+  BUGZ_LOG(error) << "Logging level:" << log_level;
 
   /*
   try {