aboutsummaryrefslogtreecommitdiff
path: root/liblog/logging.cpp
diff options
context:
space:
mode:
authorDennis Brentjes <d.brentjes@gmail.com>2016-09-22 16:05:07 +0200
committerDennis Brentjes <d.brentjes@gmail.com>2016-09-22 16:05:07 +0200
commitcfae7b4dd30282209debec1d7680be8d974d0e46 (patch)
treec8e64797f0cdf74bff367b057826f81b512db624 /liblog/logging.cpp
parentf77ce5a0226014c811a46d8ab1ba8c9164768ed3 (diff)
downloadcmix-cfae7b4dd30282209debec1d7680be8d974d0e46.tar.gz
cmix-cfae7b4dd30282209debec1d7680be8d974d0e46.tar.bz2
cmix-cfae7b4dd30282209debec1d7680be8d974d0e46.zip
Added a logging facility using boost::log::trivial.
Diffstat (limited to 'liblog/logging.cpp')
-rw-r--r--liblog/logging.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/liblog/logging.cpp b/liblog/logging.cpp
new file mode 100644
index 0000000..c92247c
--- /dev/null
+++ b/liblog/logging.cpp
@@ -0,0 +1,28 @@
+
+#include "logging.hpp"
+
+#include <boost/log/core.hpp>
+#include <boost/log/expressions.hpp>
+#include <boost/log/sinks/text_file_backend.hpp>
+#include <boost/log/utility/setup/file.hpp>
+#include <boost/log/utility/setup/common_attributes.hpp>
+#include <boost/log/sources/severity_logger.hpp>
+#include <boost/log/sources/record_ostream.hpp>
+
+void init_logging(boost::log::trivial::severity_level log_level)
+{
+ boost::log::add_common_attributes();
+ boost::log::register_simple_formatter_factory< boost::log::trivial::severity_level, char >("Severity");
+
+ boost::log::add_file_log
+ (
+ boost::log::keywords::file_name = "node%N.log",
+ boost::log::keywords::rotation_size = 10 * 1024 * 1024,
+ boost::log::keywords::format = "[%Severity%] (%TimeStamp%): %Message%"
+ );
+
+ boost::log::core::get()->set_filter
+ (
+ boost::log::trivial::severity >= log_level
+ );
+}