|
@@ -17,6 +17,7 @@
|
|
|
#include <boost/log/utility/setup/file.hpp>
|
|
|
#include <cstdlib>
|
|
|
#include <fstream>
|
|
|
+#include <iomanip>
|
|
|
#include <iostream>
|
|
|
#include <map>
|
|
|
#include <string>
|
|
@@ -24,8 +25,9 @@
|
|
|
#include "config.h"
|
|
|
#include "session.h"
|
|
|
|
|
|
-#include <boost/date_time/posix_time/posix_time_types.hpp>
|
|
|
+// #include <boost/date_time/posix_time/posix_time_types.hpp>
|
|
|
#include <boost/log/expressions.hpp>
|
|
|
+#include <boost/log/support/date_time.hpp>
|
|
|
|
|
|
/*
|
|
|
boost log linking -
|
|
@@ -33,18 +35,16 @@ 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) {
|
|
|
// because TimeStamp is missing by default.
|
|
|
boost::log::add_common_attributes();
|
|
|
-
|
|
|
auto fmtScope = boost::log::expressions::format_named_scope(
|
|
|
"Scope", boost::log::keywords::format = "%n(%f:%l)",
|
|
|
- // boost::log::keywords::iteration = boost::log::expressions::reverse,
|
|
|
- boost::log::keywords::depth = 2);
|
|
|
-
|
|
|
- auto fmtTimeStamp =
|
|
|
- boost::log::expressions::format_date_time<boost::posix_time::ptime>(
|
|
|
- "TimeStamp", "%Y-%m-%d %H:%M:%S.%f");
|
|
|
+ boost::log::keywords::iteration = boost::log::expressions::reverse,
|
|
|
+ boost::log::keywords::depth = 3);
|
|
|
|
|
|
boost::log::add_file_log(
|
|
|
// This gives dated logfile name.
|
|
@@ -52,19 +52,14 @@ void init_logging(void) {
|
|
|
// This appends to the logfile (instead of overwrite)
|
|
|
boost::log::keywords::open_mode = std::ios_base::out | std::ios_base::app,
|
|
|
|
|
|
+ // boost::log::keywords::format = "[%TimeStamp%] %Severity% : %Message%"
|
|
|
boost::log::keywords::format =
|
|
|
- (boost::log::expressions::stream <<
|
|
|
- // <<
|
|
|
- // boost::log::expressions::attr<boost::posix_time::ptime>("TimeStamp")
|
|
|
- // <<
|
|
|
- fmtTimeStamp <<
|
|
|
- // << boost::log::expressions::attr<unsigned int>("LineID") <<
|
|
|
- ": <" << boost::log::trivial::severity << " [" << fmtScope << "] "
|
|
|
- << "> "
|
|
|
- << boost::log::expressions::smessage)
|
|
|
-
|
|
|
- // boost::log::keywords::format = "[%TimeStamp%] %Severity% %Scope% :
|
|
|
- // %Message%",
|
|
|
+ (boost::log::expressions::stream
|
|
|
+ << boost::log::expressions::format_date_time<
|
|
|
+ boost::posix_time::ptime>("TimeStamp", "%H:%M:%S.%f")
|
|
|
+ << " " << std::setw(8) << boost::log::trivial::severity << " "
|
|
|
+ << fmtScope << " : " << boost::log::expressions::smessage)
|
|
|
+
|
|
|
);
|
|
|
|
|
|
auto core = boost::log::core::get();
|
|
@@ -87,6 +82,7 @@ int main(int argc, char *argv[]) {
|
|
|
}
|
|
|
|
|
|
init_logging();
|
|
|
+ BOOST_LOG_NAMED_SCOPE("main");
|
|
|
|
|
|
std::map<std::string, std::string> config = yaml_parse(argv[1]);
|
|
|
|