Clio develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
util::LogServiceState Class Reference

Base state management class for the logging service. More...

#include <Logger.hpp>

Inheritance diagram for util::LogServiceState:

Static Protected Member Functions

static void init (bool isAsync, Severity defaultSeverity, std::vector< std::shared_ptr< spdlog::sinks::sink > > const &sinks)
 Initialize the logging core with specified parameters.
 
static bool initialized ()
 Whether the LogService is initialized or not.
 
static void reset ()
 Reset the logging service to uninitialized state.
 
static void replaceSinks (std::vector< std::shared_ptr< spdlog::sinks::sink > > const &sinks)
 Replace the current sinks with a new set of sinks.
 
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.
 

Static Protected Attributes

static bool isAsync_ {true}
 
static Severity defaultSeverity_ {Severity::NFO}
 
static std::vector< std::shared_ptr< spdlog::sinks::sink > > sinks_ {}
 
static bool initialized_ {false}
 

Friends

struct ::LogServiceInitTests
 
class ::LoggerFixture
 
class Logger
 
class ::util::impl::OnAssert
 

Detailed Description

Base state management class for the logging service.

This class manages the global state and core functionality for the logging system, including initialization, sink management, and logger registration.

Member Function Documentation

◆ init()

void util::LogServiceState::init ( bool isAsync,
Severity defaultSeverity,
std::vector< std::shared_ptr< spdlog::sinks::sink > > const & sinks )
staticprotected

Initialize the logging core with specified parameters.

Parameters
isAsyncWhether logging should be asynchronous
defaultSeverityThe default severity level for new loggers
sinksVector of spdlog sinks to use for output

◆ initialized()

bool util::LogServiceState::initialized ( )
staticnodiscardprotected

Whether the LogService is initialized or not.

Returns
true if the LogService is initialized

◆ registerLogger()

std::shared_ptr< spdlog::logger > util::LogServiceState::registerLogger ( std::string const & channel,
std::optional< Severity > severity = std::nullopt )
staticprotected

Register a new logger for the specified channel.

Creates and registers a new spdlog logger instance for the given channel with the specified or default severity level.

Parameters
channelThe name of the logging channel
severityOptional severity level override; uses default if not specified
Returns
Shared pointer to the registered spdlog logger

◆ replaceSinks()

void util::LogServiceState::replaceSinks ( std::vector< std::shared_ptr< spdlog::sinks::sink > > const & sinks)
staticprotected

Replace the current sinks with a new set of sinks.

Parameters
sinksVector of new spdlog sinks to replace the current ones

The documentation for this class was generated from the following files: