-
Notifications
You must be signed in to change notification settings - Fork 85
/
logger.cpp
44 lines (37 loc) · 1.56 KB
/
logger.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <boost/log/trivial.hpp>
#include <boost/log/expressions.hpp>
#include <boost/log/utility/setup/file.hpp>
#include <boost/log/sources/record_ostream.hpp>
#include <boost/log/utility/setup/common_attributes.hpp>
#include <boost/log/utility/setup/console.hpp>
#include <boost/log/support/date_time.hpp>
void init_framework_logging(const std::string & full_file_name){
boost::log::add_file_log(
boost::log::keywords::file_name = full_file_name + "_%Y%m%d.log",
boost::log::keywords::open_mode = (std::ios::out | std::ios::app),
boost::log::keywords::auto_flush = true,
boost::log::keywords::format =
(
boost::log::expressions::stream
<< boost::log::expressions::format_date_time< boost::posix_time::ptime >("TimeStamp", "%H:%M:%S.%f")
<< ": <" << boost::log::trivial::severity
<< "> " << boost::log::expressions::smessage
)
);
boost::log::add_console_log(
std::cout,
boost::log::keywords::format =
(
boost::log::expressions::stream
<< boost::log::expressions::format_date_time< boost::posix_time::ptime >("TimeStamp", "%H:%M:%S.%f")
<< ": <" << boost::log::trivial::severity
<< "> " << boost::log::expressions::smessage
)
);
boost::log::add_common_attributes();
#ifdef NDEBUG
boost::log::core::get()->set_filter (
boost::log::trivial::severity >= boost::log::trivial::info
);
#endif
}