22#include "util/SourceLocation.hpp"
46struct BenchmarkLoggingInitializer;
48struct LogServiceInitTests;
65#ifndef COVERAGE_ENABLED
67 if (auto clio_pump__ = x; not clio_pump__) { \
95 std::shared_ptr<spdlog::logger> logger_;
97 friend class LogService;
98 friend struct ::BenchmarkLoggingInitializer;
104 std::shared_ptr<spdlog::logger> logger_;
106 SourceLocationType
const sourceLocation_;
107 std::ostringstream stream_;
113 Pump(std::shared_ptr<spdlog::logger> logger,
Severity sev, SourceLocationType
const& loc);
115 Pump(Pump&&) =
delete;
116 Pump(Pump
const&) =
delete;
118 operator=(Pump
const&) =
delete;
120 operator=(Pump&&) =
delete;
129 template <
typename T>
130 [[maybe_unused]] Pump&
134 stream_ << std::forward<T>(
data);
141 operator bool()
const
148 static constexpr std::array<char const*, 8> kCHANNELS = {
168 Logger(std::string channel);
175 operator=(
Logger const&) =
default;
178 operator=(
Logger&&) =
default;
187 trace(SourceLocationType
const& loc = CURRENT_SRC_LOCATION)
const;
196 debug(SourceLocationType
const& loc = CURRENT_SRC_LOCATION)
const;
205 info(SourceLocationType
const& loc = CURRENT_SRC_LOCATION)
const;
214 warn(SourceLocationType
const& loc = CURRENT_SRC_LOCATION)
const;
223 error(SourceLocationType
const& loc = CURRENT_SRC_LOCATION)
const;
232 fatal(SourceLocationType
const& loc = CURRENT_SRC_LOCATION)
const;
235 Logger(std::shared_ptr<spdlog::logger> logger);
246 friend struct ::LogServiceInitTests;
247 friend class ::LoggerFixture;
249 friend class ::util::impl::OnAssert;
259 init(
bool isAsync,
Severity defaultSeverity, std::vector<std::shared_ptr<spdlog::sinks::sink>>
const& sinks);
266 [[nodiscard]]
static bool
281 replaceSinks(std::vector<std::shared_ptr<spdlog::sinks::sink>>
const& sinks);
293 static std::shared_ptr<spdlog::logger>
294 registerLogger(std::string
const& channel, std::optional<Severity> severity = std::nullopt);
297 static bool isAsync_;
299 static std::vector<std::shared_ptr<spdlog::sinks::sink>> sinks_;
300 static bool initialized_;
311 LogService() =
delete;
319 [[nodiscard]]
static std::expected<void, std::string>
334 [[nodiscard]]
static Logger::Pump
335 trace(SourceLocationType
const& loc = CURRENT_SRC_LOCATION);
343 [[nodiscard]]
static Logger::Pump
344 debug(SourceLocationType
const& loc = CURRENT_SRC_LOCATION);
352 [[nodiscard]]
static Logger::Pump
353 info(SourceLocationType
const& loc = CURRENT_SRC_LOCATION);
361 [[nodiscard]]
static Logger::Pump
362 warn(SourceLocationType
const& loc = CURRENT_SRC_LOCATION);
370 [[nodiscard]]
static Logger::Pump
371 error(SourceLocationType
const& loc = CURRENT_SRC_LOCATION);
379 [[nodiscard]]
static Logger::Pump
380 fatal(SourceLocationType
const& loc = CURRENT_SRC_LOCATION);
389 [[nodiscard]]
static std::expected<std::vector<std::shared_ptr<spdlog::sinks::sink>>, std::string>
392 struct FileLoggingParams {
395 uint32_t rotationSizeMB;
396 uint32_t dirMaxFiles;
399 friend struct ::BenchmarkLoggingInitializer;
402 static std::shared_ptr<spdlog::sinks::sink>
403 createFileSink(FileLoggingParams
const& params, std::string
const& format);
Base state management class for the logging service.
Definition Logger.hpp:244
static bool initialized()
Whether the LogService is initialized or not.
Definition Logger.cpp:269
static std::shared_ptr< spdlog::logger > registerLogger(std::string const &channel, std::optional< Severity > severity=std::nullopt)
Register a new logger for the specified channel.
Definition Logger.cpp:287
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:424
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 Logger::Pump error(SourceLocationType const &loc=CURRENT_SRC_LOCATION)
Globally accessible General logger at Severity::ERR severity.
Definition Logger.cpp:412
static Logger::Pump debug(SourceLocationType const &loc=CURRENT_SRC_LOCATION)
Globally accessible General logger at Severity::DBG severity.
Definition Logger.cpp:394
static Logger::Pump warn(SourceLocationType const &loc=CURRENT_SRC_LOCATION)
Globally accessible General logger at Severity::WRN severity.
Definition Logger.cpp:406
static void shutdown()
Shutdown spdlog to guarantee output is not lost.
Definition Logger.cpp:379
static std::expected< void, std::string > init(config::ClioConfigDefinition const &config)
Global log core initialization from a config::ClioConfigDefinition.
Definition Logger.cpp:345
static Logger::Pump fatal(SourceLocationType const &loc=CURRENT_SRC_LOCATION)
Globally accessible General logger at Severity::FTL severity.
Definition Logger.cpp:418
static Logger::Pump trace(SourceLocationType const &loc=CURRENT_SRC_LOCATION)
Globally accessible General logger at Severity::TRC severity.
Definition Logger.cpp:388
static Logger::Pump info(SourceLocationType const &loc=CURRENT_SRC_LOCATION)
Globally accessible General logger at Severity::NFO severity.
Definition Logger.cpp:400
Logger(std::string channel)
Construct a new Logger object that produces loglines for the specified channel.
Definition Logger.cpp:430
Pump warn(SourceLocationType const &loc=CURRENT_SRC_LOCATION) const
Interface for logging at Severity::WRN severity.
Definition Logger.cpp:468
Pump error(SourceLocationType const &loc=CURRENT_SRC_LOCATION) const
Interface for logging at Severity::ERR severity.
Definition Logger.cpp:473
Pump fatal(SourceLocationType const &loc=CURRENT_SRC_LOCATION) const
Interface for logging at Severity::FTL severity.
Definition Logger.cpp:478
Pump debug(SourceLocationType const &loc=CURRENT_SRC_LOCATION) const
Interface for logging at Severity::DBG severity.
Definition Logger.cpp:458
Pump trace(SourceLocationType const &loc=CURRENT_SRC_LOCATION) const
Interface for logging at Severity::TRC severity.
Definition Logger.cpp:453
Pump info(SourceLocationType const &loc=CURRENT_SRC_LOCATION) const
Interface for logging at Severity::NFO severity.
Definition Logger.cpp:463
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:77