cpp-toolbox  0.0.1
A toolbox library for C++
Loading...
Searching...
No Matches
toolbox::logger::thread_logger_t::thread_format_logger_t Class Reference

基于格式的日志记录器,用于printf风格的消息格式化 / Format-based logger for printf-style message formatting More...

#include <thread_logger.hpp>

Public Member Functions

 thread_format_logger_t (thread_logger_t &logger, Level level)
 使用特定日志级别构造格式日志记录器 / Construct a format logger with a specific logging level
 
template<typename... Args>
void operator() (const char *format, Args &&... args)
 记录格式化消息 / Log a formatted message
 

Detailed Description

基于格式的日志记录器,用于printf风格的消息格式化 / Format-based logger for printf-style message formatting

thread_format_logger_t类提供了一种使用printf风格格式字符串记录消息的线程安全方式。它支持形式为{}的格式说明符,这些说明符将被提供的参数替换。/ The thread_format_logger_t class provides a thread-safe way to log messages using a printf-style format string. It supports format specifiers of the form {} which are replaced with the provided arguments.

Note
只有当消息的级别等于或高于当前日志级别时才会记录消息 / Messages are only logged if their level is equal to or higher than the current logging level
logger("Processing {} of {} items", processed_count, total_items);
基于格式的日志记录器,用于printf风格的消息格式化 / Format-based logger for printf-style message formatting
Definition thread_logger.hpp:325
@ INFO
一般操作消息 / General operational messages
static auto instance() -> thread_logger_t &
获取日志记录器的单例实例 / Get the singleton instance of the logger

Constructor & Destructor Documentation

◆ thread_format_logger_t()

toolbox::logger::thread_logger_t::thread_format_logger_t::thread_format_logger_t ( thread_logger_t logger,
Level  level 
)

使用特定日志级别构造格式日志记录器 / Construct a format logger with a specific logging level

Parameters
logger对父thread_logger_t实例的引用 / Reference to the parent thread_logger_t instance
level此日志记录器的日志级别 / The logging level for messages from this logger

Member Function Documentation

◆ operator()()

template<typename... Args>
void toolbox::logger::thread_logger_t::thread_format_logger_t::operator() ( const char *  format,
Args &&...  args 
)
inline

记录格式化消息 / Log a formatted message

Template Parameters
Args格式参数的类型 / Types of the format arguments
Parameters
format包含{}占位符的格式字符串 / The format string containing {} placeholders
args要插入格式字符串的值 / The values to insert into the format string

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