pflib v3.9.0-rc3-11-g2537d8f
Pretty Fine HGCROC Interaction Library
Loading...
Searching...
No Matches
Logging.h
1#pragma once
2
3#ifndef BOOST_LOG_DYN_LINK
4#define BOOST_LOG_DYN_LINK
5#endif
6
7#include <boost/log/core.hpp> //core logging service
8#include <boost/log/sources/record_ostream.hpp>
9#include <boost/log/sources/severity_channel_logger.hpp> //for the severity logger
10#include <boost/log/sources/severity_feature.hpp> //for the severity feature in a logger
11
15namespace pflib::logging {
16
20enum level { trace = -1, debug = 0, info = 1, warn = 2, error = 3, fatal = 4 };
21
31level convert(int i_lvl);
32
39using logger =
40 boost::log::sources::severity_channel_logger_mt<level, std::string>;
41
54logger get(const std::string& name);
55
65void open(bool color);
66
73void set(level lvl, const std::string& only = "");
74
78void close();
79
97struct fixture {
104 fixture();
105
107 ~fixture();
108};
109
110} // namespace pflib::logging
111
129#define pflib_log(lvl) BOOST_LOG_SEV(the_log_, ::pflib::logging::level::lvl)
hold logging infrastructure in namespace
Definition Logging.cxx:14
void open(bool color)
Initialize the logging backend.
Definition Logging.cxx:112
boost::log::sources::severity_channel_logger_mt< level, std::string > logger
our logger type
Definition Logging.h:39
void close()
Close up the logging.
Definition Logging.cxx:146
level
logging severity labels and their corresponding integers
Definition Logging.h:20
void set(level lvl, const std::string &only)
Change the level for the logs.
Definition Logging.cxx:137
logger get(const std::string &name)
Gets a logger with the input name for its channel.
Definition Logging.cxx:24
level convert(int i_lvl)
convert an integer to the severity level enum
Definition Logging.cxx:16
a "fixture" that opens the logging when it is created and closes the logging when it is destroyed.
Definition Logging.h:97
fixture()
constructor to open logging and provide an initial configuration
Definition Logging.cxx:148
~fixture()
destructor to close logging
Definition Logging.cxx:153