LDMX Software
Logger.h
1#ifndef FRAMEWORK_LOGGER_H
2#define FRAMEWORK_LOGGER_H
3
10#define BOOST_ALL_DYN_LINK 1
11
12#include <boost/log/core.hpp> //core logging service
13#include <boost/log/expressions.hpp> //for attributes and expressions
14#include <boost/log/sinks/sync_frontend.hpp> //syncronous sink frontend
15#include <boost/log/sinks/text_ostream_backend.hpp> //output stream sink backend
16#include <boost/log/sources/global_logger_storage.hpp> //for global logger default
17#include <boost/log/sources/severity_channel_logger.hpp> //for the severity logger
18#include <boost/log/sources/severity_feature.hpp> //for the severity feature in a logger
19#include <boost/log/utility/setup/common_attributes.hpp>
20
21// TODO check which headers are required
22#include <boost/log/sources/record_ostream.hpp>
23#include <boost/log/utility/setup/file.hpp>
24
25#include "Framework/Configure/Parameters.h"
26
27namespace framework {
28
29namespace logging {
30
34enum level {
35 debug = 0,
36 info,
37 warn,
38 error,
39 fatal
40};
41
45namespace log = boost::log;
46namespace sinks = boost::log::sinks;
47
51typedef log::sources::severity_channel_logger_mt<level, std::string> logger;
52
65logger makeLogger(const std::string& name);
66
78void open(const framework::config::Parameters& p);
79
83void close();
84
93class Formatter {
94 int event_number_{0};
95 Formatter() = default;
96
97 public:
99 Formatter(Formatter const&) = delete;
100
102 void operator=(Formatter const&) = delete;
103
105 static Formatter& get();
106
108 static void set(int n);
109
117 void operator()(const log::record_view& view, log::formatting_ostream& os);
118};
119
120} // namespace logging
121
122} // namespace framework
123
137#define enableLogging(name) \
138 mutable ::framework::logging::logger theLog_{ \
139 ::framework::logging::makeLogger(name)};
140
147#define ldmx_log(lvl) BOOST_LOG_SEV(theLog_, ::framework::logging::level::lvl)
148
149#endif // FRAMEWORK_LOGGER_H
Class encapsulating parameters for configuring a processor.
Definition Parameters.h:27
Our logging formatter.
Definition Logger.h:93
Formatter(Formatter const &)=delete
delete the copy constructor
void operator=(Formatter const &)=delete
delete the assignment operator
void operator()(const log::record_view &view, log::formatting_ostream &os)
format the passed record view into the output stream
Definition Logger.cxx:162
static Formatter & get()
get reference to the current single Formatter
Definition Logger.cxx:155
static void set(int n)
set the event number in the current Formatter
Definition Logger.cxx:160
All classes in the ldmx-sw project use this namespace.
Definition PerfDict.cxx:45