LDMX Software
Logger.h
1#ifndef FRAMEWORK_LOGGER_H
2#define FRAMEWORK_LOGGER_H
3
10#define BOOST_ALL_DYN_LINK 1
11
12// Keep this list minimal, every processor includes it (see issue #2107).
13// Sinks, expressions, and setup headers belong in Logger.cxx.
14#include <boost/log/core/record_view.hpp>
15#include <boost/log/sources/record_ostream.hpp> // IWYU pragma: keep, BOOST_LOG_SEV
16#include <boost/log/sources/severity_channel_logger.hpp>
17#include <boost/log/utility/formatting_ostream_fwd.hpp>
18#include <string>
19
20namespace framework {
21
22namespace config {
23class Parameters;
24} // namespace config
25
26namespace logging {
27
31enum level {
32 trace = -1,
33 debug = 0,
34 info,
35 warn,
36 error,
37 fatal
38};
39
43namespace log = boost::log;
44
48typedef log::sources::severity_channel_logger_mt<level, std::string> logger;
49
62logger makeLogger(const std::string& name);
63
75void open(const framework::config::Parameters& p);
76
80void close();
81
90class Formatter {
91 int event_number_{0};
92 Formatter() = default;
93
94 public:
96 Formatter(Formatter const&) = delete;
97
99 void operator=(Formatter const&) = delete;
100
102 static Formatter& get();
103
105 static void set(int n);
106
114 void operator()(const log::record_view& view, log::formatting_ostream& os);
115};
116
117} // namespace logging
118
119} // namespace framework
120
134#define enableLogging(name) \
135 mutable ::framework::logging::logger the_log_{ \
136 ::framework::logging::makeLogger(name)};
137
144// NOLINTNEXTLINE(readability-identifier-naming)
145#define ldmx_log(lvl) BOOST_LOG_SEV(the_log_, ::framework::logging::level::lvl)
146
147#endif // FRAMEWORK_LOGGER_H
Class encapsulating parameters for configuring a processor.
Definition Parameters.h:26
Our logging formatter.
Definition Logger.h:90
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:175
static Formatter & get()
get reference to the current single Formatter
Definition Logger.cxx:168
static void set(int n)
set the event number in the current Formatter
Definition Logger.cxx:173
All classes in the ldmx-sw project use this namespace.