3#include "util/SourceLocation.hpp"
28struct BenchmarkLoggingInitializer;
30struct LogServiceInitTests;
48#ifndef COVERAGE_ENABLED
50 if (auto clio_pump__ = x; not clio_pump__) { \
78 std::shared_ptr<spdlog::logger> logger_;
80 friend class LogService;
81 friend struct ::BenchmarkLoggingInitializer;
87 std::shared_ptr<spdlog::logger> logger_;
89 SourceLocationType
const sourceLocation_;
90 std::ostringstream stream_;
96 Pump(std::shared_ptr<spdlog::logger> logger,
Severity sev, SourceLocationType
const& loc);
98 Pump(Pump&&) =
delete;
99 Pump(Pump
const&) =
delete;
101 operator=(Pump
const&) =
delete;
103 operator=(Pump&&) =
delete;
113 template <
typename T>
114 [[maybe_unused]] Pump&
118 stream_ << std::forward<T>(
data);
125 operator bool()
const
132 static constexpr std::array<std::string_view, 8> kCHANNELS = {
152 Logger(std::string_view
const channel);
159 operator=(
Logger const&) =
default;
162 operator=(
Logger&&) =
default;
171 trace(SourceLocationType
const& loc = CURRENT_SRC_LOCATION)
const;
180 debug(SourceLocationType
const& loc = CURRENT_SRC_LOCATION)
const;
189 info(SourceLocationType
const& loc = CURRENT_SRC_LOCATION)
const;
198 warn(SourceLocationType
const& loc = CURRENT_SRC_LOCATION)
const;
207 error(SourceLocationType
const& loc = CURRENT_SRC_LOCATION)
const;
216 fatal(SourceLocationType
const& loc = CURRENT_SRC_LOCATION)
const;
219 Logger(std::shared_ptr<spdlog::logger> logger);
230 friend struct ::LogServiceInitTests;
231 friend class ::LoggerFixture;
233 friend class ::util::impl::OnAssert;
246 std::vector<std::shared_ptr<spdlog::sinks::sink>>
const& sinks
254 [[nodiscard]]
static bool
263 [[nodiscard]]
static bool
278 replaceSinks(std::vector<std::shared_ptr<spdlog::sinks::sink>>
const& sinks);
290 static std::shared_ptr<spdlog::logger>
291 registerLogger(std::string_view channel, std::optional<Severity> severity = std::nullopt);
294 static bool isAsync_;
296 static std::vector<std::shared_ptr<spdlog::sinks::sink>>
298 static bool initialized_;
309 LogService() =
delete;
317 [[nodiscard]]
static std::expected<void, std::string>
332 [[nodiscard]]
static Logger::Pump
333 trace(SourceLocationType
const& loc = CURRENT_SRC_LOCATION);
341 [[nodiscard]]
static Logger::Pump
342 debug(SourceLocationType
const& loc = CURRENT_SRC_LOCATION);
350 [[nodiscard]]
static Logger::Pump
351 info(SourceLocationType
const& loc = CURRENT_SRC_LOCATION);
359 [[nodiscard]]
static Logger::Pump
360 warn(SourceLocationType
const& loc = CURRENT_SRC_LOCATION);
368 [[nodiscard]]
static Logger::Pump
369 error(SourceLocationType
const& loc = CURRENT_SRC_LOCATION);
377 [[nodiscard]]
static Logger::Pump
378 fatal(SourceLocationType
const& loc = CURRENT_SRC_LOCATION);
387 [[nodiscard]]
static std::
388 expected<std::vector<std::shared_ptr<spdlog::sinks::sink>>, std::string>
391 struct FileLoggingParams {
394 uint32_t rotationSizeMB;
395 uint32_t dirMaxFiles;
398 friend struct ::BenchmarkLoggingInitializer;
401 static std::shared_ptr<spdlog::sinks::sink>
402 createFileSink(FileLoggingParams
const& params, std::string
const& format);
Base state management class for the logging service.
Definition Logger.hpp:228
static bool initialized()
Whether the LogService is initialized or not.
Definition Logger.cpp:261
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:430
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:234
static void reset()
Reset the logging service to uninitialized state.
Definition Logger.cpp:273
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:285
static bool hasSinks()
Whether the LogService has any sink. If there is no sink, logger will not log messages anywhere.
Definition Logger.cpp:267
static Logger::Pump error(SourceLocationType const &loc=CURRENT_SRC_LOCATION)
Globally accessible General logger at Severity::ERR severity.
Definition Logger.cpp:418
static Logger::Pump debug(SourceLocationType const &loc=CURRENT_SRC_LOCATION)
Globally accessible General logger at Severity::DBG severity.
Definition Logger.cpp:400
static Logger::Pump warn(SourceLocationType const &loc=CURRENT_SRC_LOCATION)
Globally accessible General logger at Severity::WRN severity.
Definition Logger.cpp:412
static void shutdown()
Shutdown spdlog to guarantee output is not lost.
Definition Logger.cpp:384
static std::expected< void, std::string > init(config::ClioConfigDefinition const &config)
Global log core initialization from a config::ClioConfigDefinition.
Definition Logger.cpp:350
static Logger::Pump fatal(SourceLocationType const &loc=CURRENT_SRC_LOCATION)
Globally accessible General logger at Severity::FTL severity.
Definition Logger.cpp:424
static Logger::Pump trace(SourceLocationType const &loc=CURRENT_SRC_LOCATION)
Globally accessible General logger at Severity::TRC severity.
Definition Logger.cpp:394
static Logger::Pump info(SourceLocationType const &loc=CURRENT_SRC_LOCATION)
Globally accessible General logger at Severity::NFO severity.
Definition Logger.cpp:406
Pump warn(SourceLocationType const &loc=CURRENT_SRC_LOCATION) const
Interface for logging at Severity::WRN severity.
Definition Logger.cpp:493
Pump error(SourceLocationType const &loc=CURRENT_SRC_LOCATION) const
Interface for logging at Severity::ERR severity.
Definition Logger.cpp:498
Pump fatal(SourceLocationType const &loc=CURRENT_SRC_LOCATION) const
Interface for logging at Severity::FTL severity.
Definition Logger.cpp:503
Pump debug(SourceLocationType const &loc=CURRENT_SRC_LOCATION) const
Interface for logging at Severity::DBG severity.
Definition Logger.cpp:483
Pump trace(SourceLocationType const &loc=CURRENT_SRC_LOCATION) const
Interface for logging at Severity::TRC severity.
Definition Logger.cpp:478
Pump info(SourceLocationType const &loc=CURRENT_SRC_LOCATION) const
Interface for logging at Severity::NFO severity.
Definition Logger.cpp:488
Logger(std::string_view const channel)
Construct a new Logger object that produces loglines for the specified channel.
Definition Logger.cpp:436
All the config data will be stored and extracted from this class.
Definition ConfigDefinition.hpp:31
This namespace implements the data access layer and related components.
Definition AmendmentCenter.cpp:56
This namespace contains various utilities.
Definition AccountUtils.hpp:11
Severity
Custom severity levels for util::Logger.
Definition Logger.hpp:60