29#ifndef BERTINI_LOGGING_HPP
30#define BERTINI_LOGGING_HPP
35#include <boost/log/core.hpp>
36#include <boost/log/trivial.hpp>
37#include <boost/log/expressions.hpp>
38#include <boost/log/sinks/text_file_backend.hpp>
39#include <boost/log/utility/setup/file.hpp>
40#include <boost/log/utility/setup/common_attributes.hpp>
41#include <boost/log/sources/severity_logger.hpp>
42#include <boost/log/sources/record_ostream.hpp>
49 namespace blog = boost::log;
52 namespace src = blog::sources;
53 namespace sinks = blog::sinks;
54 namespace keywords = blog::keywords;
61 using blros = blog::record_ostream;
66 return stream << static_cast<typename std::underlying_type<T>::type>(e);
92 void Init(std::string
const& name_pattern =
"bertini_%N.log",
93 std::string
const& format =
"%Message%",
94 unsigned rotation_size = 10*1024*1024,
97 AddFile(name_pattern, format, rotation_size);
100 BOOST_LOG_TRIVIAL(info) <<
"initialized logging";
106 void AddFile(std::string
const& name_pattern, std::string
const& format,
unsigned rotation_size,
bool auto_flush =
true)
110 keywords::file_name = name_pattern,
111 keywords::rotation_size = rotation_size,
112 keywords::format = format,
113 keywords::auto_flush = auto_flush
126 blog::core::get()->set_filter
128 blog::trivial::severity >= new_level
Definition logging.hpp:45
blros & operator<<(typename std::enable_if< std::is_enum< T >::value, blros >::type &stream, const T &e)
Stream-insertion of an enum into a log record, via its underlying integer type.
Definition logging.hpp:64
blog::trivial::severity_level severity_level
The logging severity level type (from Boost.Log).
Definition logging.hpp:51
blog::record_ostream blros
Shorthand for the Boost.Log record output stream type.
Definition logging.hpp:61
Definition algorithm_builder.hpp:36
Definition logging.hpp:88
static void Init(std::string const &name_pattern="bertini_%N.log", std::string const &format="%Message%", unsigned rotation_size=10 *1024 *1024, severity_level const &new_level=severity_level::error)
Initialize Bertini2 logging (call once); adds a rotating log file and sets the level.
Definition logging.hpp:92
static void SetLevel(severity_level const &new_level)
trivial logger-provided severity levels are
Definition logging.hpp:124
static void AddFile(std::string const &name_pattern, std::string const &format, unsigned rotation_size, bool auto_flush=true)
Add a rotating log-file sink with the given name pattern, format, and rotation size.
Definition logging.hpp:106