22#include "util/SourceLocation.hpp"
47struct BenchmarkLoggingInitializer;
49struct LogServiceInitTests;
66#ifndef COVERAGE_ENABLED
68 if (auto clio_pump__ = x; not clio_pump__) { \
96 std::shared_ptr<spdlog::logger> logger_;
98 friend class LogService;
99 friend struct ::BenchmarkLoggingInitializer;
105 std::shared_ptr<spdlog::logger> logger_;
107 SourceLocationType
const sourceLocation_;
108 std::ostringstream stream_;
114 Pump(std::shared_ptr<spdlog::logger> logger,
Severity sev, SourceLocationType
const& loc);
116 Pump(Pump&&) =
delete;
117 Pump(Pump
const&) =
delete;
119 operator=(Pump
const&) =
delete;
121 operator=(Pump&&) =
delete;
130 template <
typename T>
131 [[maybe_unused]] Pump&
135 stream_ << std::forward<T>(
data);
142 operator bool()
const
149 static constexpr std::array<std::string_view, 8> kCHANNELS = {
169 Logger(std::string_view
const channel);
176 operator=(
Logger const&) =
default;
179 operator=(
Logger&&) =
default;
188 trace(SourceLocationType
const& loc = CURRENT_SRC_LOCATION)
const;
197 debug(SourceLocationType
const& loc = CURRENT_SRC_LOCATION)
const;
206 info(SourceLocationType
const& loc = CURRENT_SRC_LOCATION)
const;
215 warn(SourceLocationType
const& loc = CURRENT_SRC_LOCATION)
const;
224 error(SourceLocationType
const& loc = CURRENT_SRC_LOCATION)
const;
233 fatal(SourceLocationType
const& loc = CURRENT_SRC_LOCATION)
const;
236 Logger(std::shared_ptr<spdlog::logger> logger);
247 friend struct ::LogServiceInitTests;
248 friend class ::LoggerFixture;
250 friend class ::util::impl::OnAssert;
260 init(
bool isAsync,
Severity defaultSeverity, std::vector<std::shared_ptr<spdlog::sinks::sink>>
const& sinks);
267 [[nodiscard]]
static bool
282 replaceSinks(std::vector<std::shared_ptr<spdlog::sinks::sink>>
const& sinks);
294 static std::shared_ptr<spdlog::logger>
295 registerLogger(std::string_view channel, std::optional<Severity> severity = std::nullopt);
298 static bool isAsync_;
300 static std::vector<std::shared_ptr<spdlog::sinks::sink>> sinks_;
301 static bool initialized_;
312 LogService() =
delete;
320 [[nodiscard]]
static std::expected<void, std::string>
335 [[nodiscard]]
static Logger::Pump
336 trace(SourceLocationType
const& loc = CURRENT_SRC_LOCATION);
344 [[nodiscard]]
static Logger::Pump
345 debug(SourceLocationType
const& loc = CURRENT_SRC_LOCATION);
353 [[nodiscard]]
static Logger::Pump
354 info(SourceLocationType
const& loc = CURRENT_SRC_LOCATION);
362 [[nodiscard]]
static Logger::Pump
363 warn(SourceLocationType
const& loc = CURRENT_SRC_LOCATION);
371 [[nodiscard]]
static Logger::Pump
372 error(SourceLocationType
const& loc = CURRENT_SRC_LOCATION);
380 [[nodiscard]]
static Logger::Pump
381 fatal(SourceLocationType
const& loc = CURRENT_SRC_LOCATION);
390 [[nodiscard]]
static std::expected<std::vector<std::shared_ptr<spdlog::sinks::sink>>, std::string>
393 struct FileLoggingParams {
396 uint32_t rotationSizeMB;
397 uint32_t dirMaxFiles;
400 friend struct ::BenchmarkLoggingInitializer;
403 static std::shared_ptr<spdlog::sinks::sink>
404 createFileSink(FileLoggingParams
const& params, std::string
const& format);
Base state management class for the logging service.
Definition Logger.hpp:245
static bool initialized()
Whether the LogService is initialized or not.
Definition Logger.cpp:269
static void replaceSinks(std::vector< std::shared_ptr< spdlog::sinks::sink > > const &sinks)
Replace the current sinks with a new set of sinks.
Definition Logger.cpp:426
static void init(bool isAsync, Severity defaultSeverity, std::vector< std::shared_ptr< spdlog::sinks::sink > > const &sinks)
Initialize the logging core with specified parameters.
Definition Logger.cpp:246
static void reset()
Reset the logging service to uninitialized state.
Definition Logger.cpp:275
static std::shared_ptr< spdlog::logger > registerLogger(std::string_view channel, std::optional< Severity > severity=std::nullopt)
Register a new logger for the specified channel.
Definition Logger.cpp:287
static Logger::Pump error(SourceLocationType const &loc=CURRENT_SRC_LOCATION)
Globally accessible General logger at Severity::ERR severity.
Definition Logger.cpp:414
static Logger::Pump debug(SourceLocationType const &loc=CURRENT_SRC_LOCATION)
Globally accessible General logger at Severity::DBG severity.
Definition Logger.cpp:396
static Logger::Pump warn(SourceLocationType const &loc=CURRENT_SRC_LOCATION)
Globally accessible General logger at Severity::WRN severity.
Definition Logger.cpp:408
static void shutdown()
Shutdown spdlog to guarantee output is not lost.
Definition Logger.cpp:381
static std::expected< void, std::string > init(config::ClioConfigDefinition const &config)
Global log core initialization from a config::ClioConfigDefinition.
Definition Logger.cpp:347
static Logger::Pump fatal(SourceLocationType const &loc=CURRENT_SRC_LOCATION)
Globally accessible General logger at Severity::FTL severity.
Definition Logger.cpp:420
static Logger::Pump trace(SourceLocationType const &loc=CURRENT_SRC_LOCATION)
Globally accessible General logger at Severity::TRC severity.
Definition Logger.cpp:390
static Logger::Pump info(SourceLocationType const &loc=CURRENT_SRC_LOCATION)
Globally accessible General logger at Severity::NFO severity.
Definition Logger.cpp:402
Pump warn(SourceLocationType const &loc=CURRENT_SRC_LOCATION) const
Interface for logging at Severity::WRN severity.
Definition Logger.cpp:485
Pump error(SourceLocationType const &loc=CURRENT_SRC_LOCATION) const
Interface for logging at Severity::ERR severity.
Definition Logger.cpp:490
Pump fatal(SourceLocationType const &loc=CURRENT_SRC_LOCATION) const
Interface for logging at Severity::FTL severity.
Definition Logger.cpp:495
Pump debug(SourceLocationType const &loc=CURRENT_SRC_LOCATION) const
Interface for logging at Severity::DBG severity.
Definition Logger.cpp:475
Pump trace(SourceLocationType const &loc=CURRENT_SRC_LOCATION) const
Interface for logging at Severity::TRC severity.
Definition Logger.cpp:470
Pump info(SourceLocationType const &loc=CURRENT_SRC_LOCATION) const
Interface for logging at Severity::NFO severity.
Definition Logger.cpp:480
Logger(std::string_view const channel)
Construct a new Logger object that produces loglines for the specified channel.
Definition Logger.cpp:432
All the config data will be stored and extracted from this class.
Definition ConfigDefinition.hpp:50
This namespace implements the data access layer and related components.
Definition AmendmentCenter.cpp:70
This namespace contains various utilities.
Definition AccountUtils.hpp:30
Severity
Custom severity levels for util::Logger.
Definition Logger.hpp:78