LibQuicR
quicr::Logger Class Referenceabstract

Abstract sink for libquicr diagnostic messages. More...

#include <log.h>

Public Types

enum class  Level {
  Trace = QUICR_LOG_TRACE , Debug = QUICR_LOG_DEBUG , Info = QUICR_LOG_INFO , Warn = QUICR_LOG_WARN ,
  Error = QUICR_LOG_ERROR , Critical = QUICR_LOG_CRITICAL , Off = QUICR_LOG_OFF
}
 Log severity in increasing order. More...
 

Public Member Functions

virtual ~Logger ()=default
 Destroy the logger. More...
 
virtual void SetLevel (Level max_level)=0
 Set the minimum severity emitted by this logger. More...
 
virtual void Log (Level level, std::string_view msg, std::source_location location=std::source_location::current())=0
 Emit an already formatted message. More...
 
virtual bool ShouldLog (Level level) const noexcept
 Determine whether a message severity is enabled at compile time. More...
 
template<typename... Args>
void Log (std::source_location location, Level level, std::conditional_t< sizeof...(Args)==0, std::string_view, std_or_fmt::format_string< Args... >> msg, Args &&... args)
 Format and emit a message if its severity is enabled. More...
 

Detailed Description

Abstract sink for libquicr diagnostic messages.

Member Enumeration Documentation

◆ Level

enum quicr::Logger::Level
strong

Log severity in increasing order.

Enumerator
Trace 

Fine-grained execution tracing.

Debug 

Diagnostic information for debugging.

Info 

Normal operational information.

Warn 

A recoverable or potentially harmful condition.

Error 

An operation failed.

Critical 

A severe failure requiring immediate attention.

Off 

Disable logging.

Constructor & Destructor Documentation

◆ ~Logger()

virtual quicr::Logger::~Logger ( )
virtualdefault

Destroy the logger.

Member Function Documentation

◆ Log() [1/2]

virtual void quicr::Logger::Log ( Level  level,
std::string_view  msg,
std::source_location  location = std::source_location::current() 
)
pure virtual

Emit an already formatted message.

Parameters
levelMessage severity.
msgMessage text; implementations must not retain the view after returning.
locationSource location associated with the logging call.

◆ Log() [2/2]

template<typename... Args>
void quicr::Logger::Log ( std::source_location  location,
Level  level,
std::conditional_t< sizeof...(Args)==0, std::string_view, std_or_fmt::format_string< Args... >>  msg,
Args &&...  args 
)
inline

Format and emit a message if its severity is enabled.

Formatting failures derived from std::exception are converted to an error log.

Template Parameters
ArgsTypes of the formatting arguments.
Parameters
locationSource location associated with the logging call.
levelMessage severity.
msgFormat string, or message text when no arguments are supplied.
argsArguments interpolated into msg.

◆ SetLevel()

virtual void quicr::Logger::SetLevel ( Level  max_level)
pure virtual

Set the minimum severity emitted by this logger.

Parameters
max_levelSeverity threshold, or Level::Off to suppress all messages.

◆ ShouldLog()

virtual bool quicr::Logger::ShouldLog ( Level  level) const
virtualnoexcept

Determine whether a message severity is enabled at compile time.

Parameters
levelSeverity to test.
Returns
true when the active compile-time level permits the message.

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