22#include "util/SourceLocation.hpp"
47struct BenchmarkLoggingInitializer;
49struct LogServiceInitTests;
67#ifndef COVERAGE_ENABLED
69 if (auto clio_pump__ = x; not clio_pump__) { \
97 std::shared_ptr<spdlog::logger> logger_;
99 friend class LogService;
100 friend struct ::BenchmarkLoggingInitializer;
106 std::shared_ptr<spdlog::logger> logger_;
108 SourceLocationType
const sourceLocation_;
109 std::ostringstream stream_;
115 Pump(std::shared_ptr<spdlog::logger> logger,
Severity sev, SourceLocationType
const& loc);
117 Pump(Pump&&) =
delete;
118 Pump(Pump
const&) =
delete;
120 operator=(Pump
const&) =
delete;
122 operator=(Pump&&) =
delete;
132 template <
typename T>
133 [[maybe_unused]] Pump&
137 stream_ << std::forward<T>(
data);
144 operator bool()
const
151 static constexpr std::array<std::string_view, 8> kCHANNELS = {
171 Logger(std::string_view
const channel);
178 operator=(
Logger const&) =
default;
181 operator=(
Logger&&) =
default;
190 trace(SourceLocationType
const& loc = CURRENT_SRC_LOCATION)
const;
199 debug(SourceLocationType
const& loc = CURRENT_SRC_LOCATION)
const;
208 info(SourceLocationType
const& loc = CURRENT_SRC_LOCATION)
const;
217 warn(SourceLocationType
const& loc = CURRENT_SRC_LOCATION)
const;
226 error(SourceLocationType
const& loc = CURRENT_SRC_LOCATION)
const;
235 fatal(SourceLocationType
const& loc = CURRENT_SRC_LOCATION)
const;
238 Logger(std::shared_ptr<spdlog::logger> logger);
249 friend struct ::LogServiceInitTests;
250 friend class ::LoggerFixture;
252 friend class ::util::impl::OnAssert;
265 std::vector<std::shared_ptr<spdlog::sinks::sink>>
const& sinks
273 [[nodiscard]]
static bool
282 [[nodiscard]]
static bool
297 replaceSinks(std::vector<std::shared_ptr<spdlog::sinks::sink>>
const& sinks);
309 static std::shared_ptr<spdlog::logger>
310 registerLogger(std::string_view channel, std::optional<Severity> severity = std::nullopt);
313 static bool isAsync_;
315 static std::vector<std::shared_ptr<spdlog::sinks::sink>>
317 static bool initialized_;
328 LogService() =
delete;
336 [[nodiscard]]
static std::expected<void, std::string>
351 [[nodiscard]]
static Logger::Pump
352 trace(SourceLocationType
const& loc = CURRENT_SRC_LOCATION);
360 [[nodiscard]]
static Logger::Pump
361 debug(SourceLocationType
const& loc = CURRENT_SRC_LOCATION);
369 [[nodiscard]]
static Logger::Pump
370 info(SourceLocationType
const& loc = CURRENT_SRC_LOCATION);
378 [[nodiscard]]
static Logger::Pump
379 warn(SourceLocationType
const& loc = CURRENT_SRC_LOCATION);
387 [[nodiscard]]
static Logger::Pump
388 error(SourceLocationType
const& loc = CURRENT_SRC_LOCATION);
396 [[nodiscard]]
static Logger::Pump
397 fatal(SourceLocationType
const& loc = CURRENT_SRC_LOCATION);
406 [[nodiscard]]
static std::
407 expected<std::vector<std::shared_ptr<spdlog::sinks::sink>>, std::string>
410 struct FileLoggingParams {
413 uint32_t rotationSizeMB;
414 uint32_t dirMaxFiles;
417 friend struct ::BenchmarkLoggingInitializer;
420 static std::shared_ptr<spdlog::sinks::sink>
421 createFileSink(FileLoggingParams
const& params, std::string
const& format);
Base state management class for the logging service.
Definition Logger.hpp:247
static bool initialized()
Whether the LogService is initialized or not.
Definition Logger.cpp:280
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:449
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:253
static void reset()
Reset the logging service to uninitialized state.
Definition Logger.cpp:292
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:304
static bool hasSinks()
Whether the LogService has any sink. If there is no sink, logger will not log messages anywhere.
Definition Logger.cpp:286
static Logger::Pump error(SourceLocationType const &loc=CURRENT_SRC_LOCATION)
Globally accessible General logger at Severity::ERR severity.
Definition Logger.cpp:437
static Logger::Pump debug(SourceLocationType const &loc=CURRENT_SRC_LOCATION)
Globally accessible General logger at Severity::DBG severity.
Definition Logger.cpp:419
static Logger::Pump warn(SourceLocationType const &loc=CURRENT_SRC_LOCATION)
Globally accessible General logger at Severity::WRN severity.
Definition Logger.cpp:431
static void shutdown()
Shutdown spdlog to guarantee output is not lost.
Definition Logger.cpp:403
static std::expected< void, std::string > init(config::ClioConfigDefinition const &config)
Global log core initialization from a config::ClioConfigDefinition.
Definition Logger.cpp:369
static Logger::Pump fatal(SourceLocationType const &loc=CURRENT_SRC_LOCATION)
Globally accessible General logger at Severity::FTL severity.
Definition Logger.cpp:443
static Logger::Pump trace(SourceLocationType const &loc=CURRENT_SRC_LOCATION)
Globally accessible General logger at Severity::TRC severity.
Definition Logger.cpp:413
static Logger::Pump info(SourceLocationType const &loc=CURRENT_SRC_LOCATION)
Globally accessible General logger at Severity::NFO severity.
Definition Logger.cpp:425
Pump warn(SourceLocationType const &loc=CURRENT_SRC_LOCATION) const
Interface for logging at Severity::WRN severity.
Definition Logger.cpp:512
Pump error(SourceLocationType const &loc=CURRENT_SRC_LOCATION) const
Interface for logging at Severity::ERR severity.
Definition Logger.cpp:517
Pump fatal(SourceLocationType const &loc=CURRENT_SRC_LOCATION) const
Interface for logging at Severity::FTL severity.
Definition Logger.cpp:522
Pump debug(SourceLocationType const &loc=CURRENT_SRC_LOCATION) const
Interface for logging at Severity::DBG severity.
Definition Logger.cpp:502
Pump trace(SourceLocationType const &loc=CURRENT_SRC_LOCATION) const
Interface for logging at Severity::TRC severity.
Definition Logger.cpp:497
Pump info(SourceLocationType const &loc=CURRENT_SRC_LOCATION) const
Interface for logging at Severity::NFO severity.
Definition Logger.cpp:507
Logger(std::string_view const channel)
Construct a new Logger object that produces loglines for the specified channel.
Definition Logger.cpp:455
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:75
This namespace contains various utilities.
Definition AccountUtils.hpp:30
Severity
Custom severity levels for util::Logger.
Definition Logger.hpp:79