格式化器类,负责将日志消息格式化为字符串
更多...
#include <format.hpp>
|
| | Formatter (const std::string &pattern="[%d{%y-%m-%d|%H:%M:%S}][%t][%c][%f:%l][%p]%T%m%n") |
| | 构造格式化器
|
| |
| std::string | Format (LogMsg &msg) |
| | 对日志消息进行格式化
|
| |
| void | Format (std::ostream &out, LogMsg &msg) |
| | 对日志消息进行格式化,并输出到指定流
|
| |
| std::string | getPattern () |
| | 获取格式化字符串
|
| |
◆ ptr
◆ Formatter()
| Xulog::Formatter::Formatter |
( |
const std::string & |
pattern = "[%d{%y-%m-%d|%H:%M:%S}][%t][%c][%f:%l][%p]%T%m%n" | ) |
|
|
inline |
构造格式化器
- 参数
-
| pattern | 格式化规则字符串,默认为"[%d{%y-%m-%d|%H:%M:%S}][%t][%c][%f:%l][%p]%T%m%n" |
- 注解
- 格式说明 d 日期,子格式{H:M:S} T 缩进 t 线程ID p 日志级别 c 日志器名称 f 文件名 l 行号 m 日志消息 n 换行
◆ createItem()
| FormatItem::ptr Xulog::Formatter::createItem |
( |
const std::string & |
key, |
|
|
const std::string & |
value |
|
) |
| |
|
inlineprivate |
根据格式化字符创建格式化子项对象
- 参数
-
- 返回
- 格式化子项的指针
◆ Format() [1/2]
| std::string Xulog::Formatter::Format |
( |
LogMsg & |
msg | ) |
|
|
inline |
◆ Format() [2/2]
| void Xulog::Formatter::Format |
( |
std::ostream & |
out, |
|
|
LogMsg & |
msg |
|
) |
| |
|
inline |
◆ getPattern()
| std::string Xulog::Formatter::getPattern |
( |
| ) |
|
|
inline |
◆ parsePattern()
| bool Xulog::Formatter::parsePattern |
( |
| ) |
|
|
inlineprivate |
◆ _items
◆ _pattern
| std::string Xulog::Formatter::_pattern |
|
private |