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

Turns a LogMessage into a line of text following a pattern. More...

#include <RST/log/Format/Formatter.hpp>

Public Member Functions

 Formatter (std::string_view pattern=DEFAULT_PATTERN)
 
void format (const LogMessage &message, std::string &dest) const
 Appends the formatted message to dest.
 
std::string format (const LogMessage &message) const
 
void setPattern (std::string_view pattern)
 
const std::string & getPattern () const noexcept
 

Static Public Attributes

static constexpr std::string_view DEFAULT_PATTERN = "[%Y-%m-%d %H:%M:%S.%e] [%l] [%n] %v"
 

Detailed Description

Turns a LogMessage into a line of text following a pattern.

Pattern codes: Y m d date, H M S e time with milliseconds, l level, L short level, n logger name, v message, f F %# source file, function and line, t thread id, P process id and %% a percent sign.

Constructor & Destructor Documentation

◆ Formatter()

RST::Log::Formatter::Formatter ( std::string_view  pattern = DEFAULT_PATTERN)
explicit

Member Function Documentation

◆ format() [1/2]

void RST::Log::Formatter::format ( const LogMessage &  message,
std::string &  dest 
) const

Appends the formatted message to dest.

◆ format() [2/2]

std::string RST::Log::Formatter::format ( const LogMessage &  message) const

◆ setPattern()

void RST::Log::Formatter::setPattern ( std::string_view  pattern)

◆ getPattern()

const std::string & RST::Log::Formatter::getPattern ( ) const
inlinenoexcept

Member Data Documentation

◆ DEFAULT_PATTERN

constexpr std::string_view RST::Log::Formatter::DEFAULT_PATTERN = "[%Y-%m-%d %H:%M:%S.%e] [%l] [%n] %v"
staticconstexpr

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