22#include "util/SourceLocation.hpp"
24#include <boost/algorithm/string/predicate.hpp>
25#include <boost/filesystem.hpp>
26#include <boost/json.hpp>
27#include <boost/json/conversion.hpp>
28#include <boost/json/value.hpp>
29#include <boost/log/core/core.hpp>
30#include <boost/log/core/record.hpp>
31#include <boost/log/expressions/filter.hpp>
32#include <boost/log/expressions/keyword.hpp>
33#include <boost/log/expressions/predicates/channel_severity_filter.hpp>
34#include <boost/log/keywords/channel.hpp>
35#include <boost/log/keywords/severity.hpp>
36#include <boost/log/sinks/unlocked_frontend.hpp>
37#include <boost/log/sources/record_ostream.hpp>
38#include <boost/log/sources/severity_channel_logger.hpp>
39#include <boost/log/sources/severity_feature.hpp>
40#include <boost/log/sources/severity_logger.hpp>
41#include <boost/log/utility/manipulators/add_value.hpp>
42#include <boost/log/utility/setup/common_attributes.hpp>
43#include <boost/log/utility/setup/console.hpp>
44#include <boost/log/utility/setup/file.hpp>
45#include <boost/log/utility/setup/formatter_parser.hpp>
56class ClioConfigDefinition;
64#ifndef COVERAGE_ENABLED
66 if (auto clio_pump__ = x; not clio_pump__) { \
87BOOST_LOG_ATTRIBUTE_KEYWORD(LogSeverity,
"Severity",
Severity);
88BOOST_LOG_ATTRIBUTE_KEYWORD(LogChannel,
"Channel", std::string);
111 using LoggerType = boost::log::sources::severity_channel_logger_mt<Severity, std::string>;
112 mutable LoggerType logger_;
120 using PumpOptType = std::optional<boost::log::aux::record_pump<LoggerType>>;
122 boost::log::record rec_;
123 PumpOptType pump_ = std::nullopt;
129 : rec_{logger.open_record(boost::log::keywords::severity = sev)}
132 pump_.emplace(boost::log::aux::make_record_pump(logger, rec_));
133 pump_->stream() << boost::log::add_value(
"SourceLocation", prettyPath(loc));
137 Pump(Pump&&) =
delete;
138 Pump(Pump
const&) =
delete;
140 operator=(Pump
const&) =
delete;
142 operator=(Pump&&) =
delete;
151 template <
typename T>
152 [[maybe_unused]] Pump&
156 pump_->stream() << std::forward<T>(
data);
163 operator bool()
const
165 return pump_.has_value();
169 [[nodiscard]]
static std::string
174 static constexpr std::array<char const*, 8> kCHANNELS = {
194 Logger(std::string channel) : logger_{boost::log::keywords::channel = channel}
203 operator=(
Logger const&) =
default;
206 operator=(
Logger&&) =
default;
272 static boost::log::filter filter;
291 [[nodiscard]]
static Logger::Pump
294 return generalLog.
trace(loc);
303 [[nodiscard]]
static Logger::Pump
306 return generalLog.
debug(loc);
315 [[nodiscard]]
static Logger::Pump
318 return generalLog.
info(loc);
327 [[nodiscard]]
static Logger::Pump
330 return generalLog.
warn(loc);
339 [[nodiscard]]
static Logger::Pump
342 return generalLog.
error(loc);
351 [[nodiscard]]
static Logger::Pump
354 return generalLog.
fatal(loc);
363 [[nodiscard]]
static Logger::Pump
366 return alertLog.
warn(loc);
A global logging service.
Definition Logger.hpp:269
static Logger::Pump alert(SourceLocationType const &loc=CURRENT_SRC_LOCATION)
Globally accesible Alert logger.
Definition Logger.hpp:364
static Logger::Pump fatal(SourceLocationType const &loc=CURRENT_SRC_LOCATION)
Globally accesible General logger at Severity::FTL severity.
Definition Logger.hpp:352
static Logger::Pump debug(SourceLocationType const &loc=CURRENT_SRC_LOCATION)
Globally accesible General logger at Severity::DBG severity.
Definition Logger.hpp:304
static Logger::Pump trace(SourceLocationType const &loc=CURRENT_SRC_LOCATION)
Globally accesible General logger at Severity::TRC severity.
Definition Logger.hpp:292
static Logger::Pump error(SourceLocationType const &loc=CURRENT_SRC_LOCATION)
Globally accesible General logger at Severity::ERR severity.
Definition Logger.hpp:340
static void init(config::ClioConfigDefinition const &config)
Global log core initialization from a Config.
Definition Logger.cpp:115
static Logger::Pump info(SourceLocationType const &loc=CURRENT_SRC_LOCATION)
Globally accesible General logger at Severity::NFO severity.
Definition Logger.hpp:316
static Logger::Pump warn(SourceLocationType const &loc=CURRENT_SRC_LOCATION)
Globally accesible General logger at Severity::WRN severity.
Definition Logger.hpp:328
A simple thread-safe logger for the channel specified in the constructor.
Definition Logger.hpp:110
Logger(std::string channel)
Construct a new Logger object that produces loglines for the specified channel.
Definition Logger.hpp:194
Pump warn(SourceLocationType const &loc=CURRENT_SRC_LOCATION) const
Interface for logging at Severity::WRN severity.
Definition Logger.cpp:210
Pump error(SourceLocationType const &loc=CURRENT_SRC_LOCATION) const
Interface for logging at Severity::ERR severity.
Definition Logger.cpp:215
Pump fatal(SourceLocationType const &loc=CURRENT_SRC_LOCATION) const
Interface for logging at Severity::FTL severity.
Definition Logger.cpp:220
Pump debug(SourceLocationType const &loc=CURRENT_SRC_LOCATION) const
Interface for logging at Severity::DBG severity.
Definition Logger.cpp:200
Pump trace(SourceLocationType const &loc=CURRENT_SRC_LOCATION) const
Interface for logging at Severity::TRC severity.
Definition Logger.cpp:195
Pump info(SourceLocationType const &loc=CURRENT_SRC_LOCATION) const
Interface for logging at Severity::NFO severity.
Definition Logger.cpp:205
A class representing the source location of the current code.
Definition SourceLocation.hpp:52
All the config data will be stored and extracted from this class.
Definition ConfigDefinition.hpp:54
This namespace implements the data access layer and related components.
Definition AmendmentCenter.cpp:70
This namespace contains various utilities.
Definition AccountUtils.hpp:30
std::ostream & operator<<(std::ostream &stream, Severity sev)
Custom labels for Severity in log output.
Definition Logger.cpp:73
Severity
Custom severity levels for util::Logger.
Definition Logger.hpp:76