RSTools 3.1.0
Versatile C++20 utility library
Loading...
Searching...
No Matches
RST::Log::Registry Class Reference

Global registry of named loggers, including the default logger used by the RST_LOG_* macros. More...

#include <RST/log/LogRegistry.hpp>

Public Member Functions

 Registry (const Registry &)=delete
 
Registry & operator= (const Registry &)=delete
 

Static Public Member Functions

static Registry & instance ()
 
static std::shared_ptr< Logger > get (std::string_view name)
 Logger named name, created on first use with the global sinks and level.
 
static std::shared_ptr< Logger > defaultLogger ()
 The logger named default, used by the RST_LOG_* macros.
 
static Logger & defaultLoggerRef ()
 Same as defaultLogger(), without the reference counting.
 
static void setGlobalLevel (LogLevel level)
 Sets the level of every logger, current and future.
 
static void addGlobalSink (std::shared_ptr< ISink > sink)
 Adds sink to every logger, current and future.
 
static void reset ()
 Removes every logger and global sink, and resets the global level.
 
static std::shared_ptr< Logger > init (std::string_view appName="app", LogLevel level=LogLevel::Info, bool toFile=false)
 Quick setup: logs from level to the console, and to <appName>.log if toFile is true.
 

Detailed Description

Global registry of named loggers, including the default logger used by the RST_LOG_* macros.

Constructor & Destructor Documentation

◆ Registry()

RST::Log::Registry::Registry ( const Registry &  )
delete

Member Function Documentation

◆ operator=()

Registry & RST::Log::Registry::operator= ( const Registry &  )
delete

◆ instance()

static Registry & RST::Log::Registry::instance ( )
static

◆ get()

static std::shared_ptr< Logger > RST::Log::Registry::get ( std::string_view  name)
static

Logger named name, created on first use with the global sinks and level.

Examples
log_basic.cpp.

◆ defaultLogger()

static std::shared_ptr< Logger > RST::Log::Registry::defaultLogger ( )
static

The logger named default, used by the RST_LOG_* macros.

◆ defaultLoggerRef()

static Logger & RST::Log::Registry::defaultLoggerRef ( )
static

Same as defaultLogger(), without the reference counting.

◆ setGlobalLevel()

static void RST::Log::Registry::setGlobalLevel ( LogLevel  level)
static

Sets the level of every logger, current and future.

◆ addGlobalSink()

static void RST::Log::Registry::addGlobalSink ( std::shared_ptr< ISink >  sink)
static

Adds sink to every logger, current and future.

◆ reset()

static void RST::Log::Registry::reset ( )
static

Removes every logger and global sink, and resets the global level.

◆ init()

static std::shared_ptr< Logger > RST::Log::Registry::init ( std::string_view  appName = "app",
LogLevel  level = LogLevel::Info,
bool  toFile = false 
)
static

Quick setup: logs from level to the console, and to <appName>.log if toFile is true.

Only the first call adds the sinks (until reset()); later calls just change the level. Returns the default logger.

Examples
log_basic.cpp.

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