GKD.RoboCtrl
载入中...
搜索中...
未找到
roboctrl::log::logable< T > 模板类 参考

用于提供日志功能的辅助基类 通过CRTP模式实现,要求派生类实现desc()方法以提供描述信息,在继承时传入派生类自身类型作为模板参数。 继承这个类后,派生类可以方便地使用log_debug、log_info、log_warn和log_error方法来记录日志,这些方法会自动包含类的描述信息。 示例: 更多...

详细描述

template<typename T>
class roboctrl::log::logable< T >

用于提供日志功能的辅助基类 通过CRTP模式实现,要求派生类实现desc()方法以提供描述信息,在继承时传入派生类自身类型作为模板参数。 继承这个类后,派生类可以方便地使用log_debug、log_info、log_warn和log_error方法来记录日志,这些方法会自动包含类的描述信息。 示例:

class MyClass : public logable<MyClass> {
public:
std::string desc() const {
return "MyClassInstance";
}
void do_something() {
log_info("Doing something with value: {}", 42);
}
};
用于提供日志功能的辅助基类 通过CRTP模式实现,要求派生类实现desc()方法以提供描述信息,在继承时传入派生类自身类型作为模板参数。 继承这个类后,派生类可以方便地使用log_debug、log_i...
Definition logger.h:178
asio::awaitable< T > awaitable
协程任务类型。
Definition async.hpp:42
auto desc(const descable auto &owner) -> std::string
获取一个可描述对象的描述信息
Definition multiton.hpp:262
模板参数
T要添加日志输出功能的类

在文件 logger.h178 行定义.

#include <logger.h>

Protected 成员函数

template<typename... Args>
requires descable<T>
void log (log_level level, std::format_string< Args... > fmt, Args &&...args) const
 输出日志
 
template<typename... Args>
void log_debug (std::format_string< Args... > fmt, Args &&...args) const
 输出debug日志
 
template<typename... Args>
void log_info (std::format_string< Args... > fmt, Args &&...args) const
 输出info日志
 
template<typename... Args>
void log_warn (std::format_string< Args... > fmt, Args &&...args) const
 输出warn日志
 
template<typename... Args>
void log_error (std::format_string< Args... > fmt, Args &&...args) const
 输出error日志
 

成员函数说明

◆ log()

template<typename T >
template<typename... Args>
requires descable<T>
void roboctrl::log::logable< T >::log ( log_level  level,
std::format_string< Args... >  fmt,
Args &&...  args 
) const
inlineprotected

输出日志

模板参数
Args参数类型
参数
level日志等级
fmt日志格式,参考std::format
args日志参数,参考std::format

在文件 logger.h189 行定义.

引用了 roboctrl::multiton::desc(), roboctrl::utils::singleton_base< logger >::instance() , 以及 roboctrl::log::logger::log().

被这些函数引用 roboctrl::log::logable< T >::log_debug(), roboctrl::log::logable< T >::log_error(), roboctrl::log::logable< T >::log_info() , 以及 roboctrl::log::logable< T >::log_warn().

◆ log_debug()

template<typename T >
template<typename... Args>
void roboctrl::log::logable< T >::log_debug ( std::format_string< Args... >  fmt,
Args &&...  args 
) const
inlineprotected

输出debug日志

模板参数
Args
参数
fmt日志格式,参考std::format
args日志参数,参考std::format

在文件 logger.h202 行定义.

引用了 roboctrl::log::logable< T >::log().

◆ log_error()

template<typename T >
template<typename... Args>
void roboctrl::log::logable< T >::log_error ( std::format_string< Args... >  fmt,
Args &&...  args 
) const
inlineprotected

输出error日志

模板参数
Args
参数
fmt日志格式,参考std::format
args日志参数,参考std::format

在文件 logger.h238 行定义.

引用了 roboctrl::log::logable< T >::log().

◆ log_info()

template<typename T >
template<typename... Args>
void roboctrl::log::logable< T >::log_info ( std::format_string< Args... >  fmt,
Args &&...  args 
) const
inlineprotected

输出info日志

模板参数
Args
参数
fmt日志格式,参考std::format
args日志参数,参考std::format

在文件 logger.h214 行定义.

引用了 roboctrl::log::logable< T >::log().

◆ log_warn()

template<typename T >
template<typename... Args>
void roboctrl::log::logable< T >::log_warn ( std::format_string< Args... >  fmt,
Args &&...  args 
) const
inlineprotected

输出warn日志

模板参数
Args
参数
fmt日志格式,参考std::format
args日志参数,参考std::format

在文件 logger.h226 行定义.

引用了 roboctrl::log::logable< T >::log().


该类的文档由以下文件生成: