fire v0.19.0
Framework for sImulation and Reconstruction of Events
Logger.h
Go to the documentation of this file.
1
6#ifndef FIRE_LOGGING_LOGGER_H
7#define FIRE_LOGGING_LOGGER_H
8
17#define BOOST_ALL_DYN_LINK 1
18
19#include <boost/log/core.hpp> //core logging service
20#include <boost/log/expressions.hpp> //for attributes and expressions
21#include <boost/log/sinks/sync_frontend.hpp> //syncronous sink frontend
22#include <boost/log/sinks/text_ostream_backend.hpp> //output stream sink backend
23#include <boost/log/sources/global_logger_storage.hpp> //for global logger default
24#include <boost/log/sources/severity_channel_logger.hpp> //for the severity logger
25#include <boost/log/sources/severity_feature.hpp> //for the severity feature in a logger
26#include <boost/log/utility/setup/common_attributes.hpp>
27
28// TODO check which headers are required
29#include <boost/log/sources/record_ostream.hpp>
30#include <boost/log/utility/setup/file.hpp>
31
32#include <unordered_map>
33
40namespace fire::logging {
41
48enum level {
50 debug = 0,
58 fatal
59};
60
70level convertLevel(int iLvl);
71
73namespace log = boost::log;
74
76namespace sinks = boost::log::sinks;
77
84using logger = log::sources::severity_channel_logger_mt<level, std::string>;
85
98logger makeLogger(const std::string& name);
99
115void open(const level termLevel, const level fileLevel,
116 const std::string& fileName);
117
121void close();
122
123} // namespace fire::logging
124
139#define ENABLE_LOGGING(name) \
140 mutable logging::logger theLog_{logging::makeLogger(#name)};
141
150#define fire_log(lvl) BOOST_LOG_SEV(theLog_, fire::logging::level::lvl)
151
152#endif // FRAMEWORK_LOGGER_H
Housing for logging infrastructure.
Definition: Logger.h:40
void open(const level termLevel, const level fileLevel, const std::string &fileName)
Initialize the logging backend.
Definition: Logger.cxx:56
void close()
Close up the logging.
Definition: Logger.cxx:131
level
Different logging levels available to fire's log.
Definition: Logger.h:48
@ debug
0
Definition: Logger.h:50
@ fatal
5
Definition: Logger.h:58
@ error
3
Definition: Logger.h:56
@ warn
2
Definition: Logger.h:54
@ info
1
Definition: Logger.h:52
logger makeLogger(const std::string &name)
Gets a logger for the user.
Definition: Logger.cxx:51
level convertLevel(int iLvl)
Convert an integer to the severity level enum.
Definition: Logger.cxx:15
log::sources::severity_channel_logger_mt< level, std::string > logger
Short names for boost::log.
Definition: Logger.h:84