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>
57class ClioConfigDefinition;
65#ifndef COVERAGE_ENABLED
67 if (auto clio_pump__ = x; not clio_pump__) { \
88BOOST_LOG_ATTRIBUTE_KEYWORD(LogSeverity,
"Severity",
Severity);
89BOOST_LOG_ATTRIBUTE_KEYWORD(LogChannel,
"Channel", std::string);
112 using LoggerType = boost::log::sources::severity_channel_logger_mt<Severity, std::string>;
113 mutable LoggerType logger_;
121 using PumpOptType = std::optional<boost::log::aux::record_pump<LoggerType>>;
123 boost::log::record rec_;
124 PumpOptType pump_ = std::nullopt;
130 : rec_{logger.open_record(boost::log::keywords::severity = sev)}
133 pump_.emplace(boost::log::aux::make_record_pump(logger, rec_));
134 pump_->stream() << boost::log::add_value(
"SourceLocation", prettyPath(loc));
138 Pump(Pump&&) =
delete;
139 Pump(Pump
const&) =
delete;
141 operator=(Pump
const&) =
delete;
143 operator=(Pump&&) =
delete;
152 template <
typename T>
153 [[maybe_unused]] Pump&
157 pump_->stream() << std::forward<T>(
data);
164 operator bool()
const
166 return pump_.has_value();
170 [[nodiscard]]
static std::string
175 static constexpr std::array<char const*, 8> kCHANNELS = {
195 Logger(std::string channel) : logger_{boost::log::keywords::channel = channel}
204 operator=(
Logger const&) =
default;
207 operator=(
Logger&&) =
default;
273 static boost::log::filter filter;
284 [[nodiscard]]
static std::expected<void, std::string>
293 [[nodiscard]]
static Logger::Pump
296 return generalLog.
trace(loc);
305 [[nodiscard]]
static Logger::Pump
308 return generalLog.
debug(loc);
317 [[nodiscard]]
static Logger::Pump
320 return generalLog.
info(loc);
329 [[nodiscard]]
static Logger::Pump
332 return generalLog.
warn(loc);
341 [[nodiscard]]
static Logger::Pump
344 return generalLog.
error(loc);
353 [[nodiscard]]
static Logger::Pump
356 return generalLog.
fatal(loc);
365 [[nodiscard]]
static Logger::Pump
368 return alertLog.
warn(loc);
376 [[nodiscard]]
static bool
A global logging service.
Definition Logger.hpp:270
static Logger::Pump alert(SourceLocationType const &loc=CURRENT_SRC_LOCATION)
Globally accesible Alert logger.
Definition Logger.hpp:366
static Logger::Pump fatal(SourceLocationType const &loc=CURRENT_SRC_LOCATION)
Globally accesible General logger at Severity::FTL severity.
Definition Logger.hpp:354
static Logger::Pump debug(SourceLocationType const &loc=CURRENT_SRC_LOCATION)
Globally accesible General logger at Severity::DBG severity.
Definition Logger.hpp:306
static std::expected< void, std::string > init(config::ClioConfigDefinition const &config)
Global log core initialization from a Config.
Definition Logger.cpp:115
static Logger::Pump trace(SourceLocationType const &loc=CURRENT_SRC_LOCATION)
Globally accesible General logger at Severity::TRC severity.
Definition Logger.hpp:294
static Logger::Pump error(SourceLocationType const &loc=CURRENT_SRC_LOCATION)
Globally accesible General logger at Severity::ERR severity.
Definition Logger.hpp:342
static bool enabled()
Whether the LogService is enabled or not.
Definition Logger.cpp:203
static Logger::Pump info(SourceLocationType const &loc=CURRENT_SRC_LOCATION)
Globally accesible General logger at Severity::NFO severity.
Definition Logger.hpp:318
static Logger::Pump warn(SourceLocationType const &loc=CURRENT_SRC_LOCATION)
Globally accesible General logger at Severity::WRN severity.
Definition Logger.hpp:330
A simple thread-safe logger for the channel specified in the constructor.
Definition Logger.hpp:111
Logger(std::string channel)
Construct a new Logger object that produces loglines for the specified channel.
Definition Logger.hpp:195
Pump warn(SourceLocationType const &loc=CURRENT_SRC_LOCATION) const
Interface for logging at Severity::WRN severity.
Definition Logger.cpp:224
Pump error(SourceLocationType const &loc=CURRENT_SRC_LOCATION) const
Interface for logging at Severity::ERR severity.
Definition Logger.cpp:229
Pump fatal(SourceLocationType const &loc=CURRENT_SRC_LOCATION) const
Interface for logging at Severity::FTL severity.
Definition Logger.cpp:234
Pump debug(SourceLocationType const &loc=CURRENT_SRC_LOCATION) const
Interface for logging at Severity::DBG severity.
Definition Logger.cpp:214
Pump trace(SourceLocationType const &loc=CURRENT_SRC_LOCATION) const
Interface for logging at Severity::TRC severity.
Definition Logger.cpp:209
Pump info(SourceLocationType const &loc=CURRENT_SRC_LOCATION) const
Interface for logging at Severity::NFO severity.
Definition Logger.cpp:219
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:77