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

Thread-safe logging: loggers, sinks, patterns and macros. More...

Namespaces

namespace  Terminal
 ANSI escape codes to style terminal output.
 

Classes

class  ASink
 Base class for sinks: handles the level, the pattern and the locking. More...
 
class  CallbackSink
 Calls a function for each message, with the LogMessage or with the level and formatted line. More...
 
class  ConsoleSink
 Writes colored lines to std::cout or another stream. More...
 
class  DebuggerSink
 Sends messages to the attached debugger on Windows; does nothing elsewhere. More...
 
class  FileSink
 Appends messages to a file. More...
 
class  Formatter
 Turns a LogMessage into a line of text following a pattern. More...
 
class  ISink
 Interface of the log destinations; derive from ASink to write a new sink. More...
 
class  Logger
 Named logger that formats messages and sends them to its sinks; thread-safe. More...
 
struct  LogMessage
 A log record as passed to the sinks. More...
 
class  LogMessageBuffer
 Copy of a LogMessage that owns its strings. More...
 
class  NullSink
 Discards every message. More...
 
class  OStreamSink
 Writes plain lines to a std::ostream, which must outlive the sink. More...
 
class  Registry
 Global registry of named loggers, including the default logger used by the RST_LOG_* macros. More...
 
class  RingBufferSink
 Keeps the latest messages in memory, to replay them into another sink later. More...
 
class  RotatingFileSink
 Writes to a file and rotates it when it grows too large. More...
 
class  ScopedTimer
 Logs the time spent in a scope when destroyed, usually through RST_LOG_SCOPE_TIME(). More...
 
class  SessionFileSink
 Writes one file per run, keeping the files of the previous runs as backups. More...
 
struct  SourceLocation
 File, function and line of a log call. More...
 

Enumerations

enum class  LogLevel : std::uint8_t {
  Trace = 0 , Debug , Info , Warn ,
  Error , Fatal , Off
}
 Severity of a message, from Trace to Fatal; Off disables logging. More...
 

Functions

constexpr std::string_view toString (LogLevel level) noexcept
 Level name, such as INFO.
 
constexpr std::string_view toShortString (LogLevel level) noexcept
 Three-letter level name, such as INF.
 
std::ostream & operator<< (std::ostream &out, LogLevel level)
 

Variables

constexpr std::size_t kLogLevelCount = static_cast<std::size_t>(LogLevel::Off) + 1
 

Detailed Description

Thread-safe logging: loggers, sinks, patterns and macros.

Registry::init() sets up the default logger used by the RST_LOG_* macros, and Registry::get() returns named loggers sharing the same sinks. A Logger can also be created and configured by hand.

Enumeration Type Documentation

◆ LogLevel

enum class RST::Log::LogLevel : std::uint8_t
strong

Severity of a message, from Trace to Fatal; Off disables logging.

Enumerator
Trace 
Debug 
Info 
Warn 
Error 
Fatal 
Off 

Function Documentation

◆ toString()

constexpr std::string_view RST::Log::toString ( LogLevel  level)
constexprnoexcept

Level name, such as INFO.

◆ toShortString()

constexpr std::string_view RST::Log::toShortString ( LogLevel  level)
constexprnoexcept

Three-letter level name, such as INF.

◆ operator<<()

std::ostream & RST::Log::operator<< ( std::ostream &  out,
LogLevel  level 
)

Variable Documentation

◆ kLogLevelCount

constexpr std::size_t RST::Log::kLogLevelCount = static_cast<std::size_t>(LogLevel::Off) + 1
inlineconstexpr