日志记录器,支持多级别、颜色输出和自动时间戳。
More...
#include <logging.h>
|
| void | set (Level minLevel) |
| | 设置最低日志级别(低于该级别的日志将被忽略)。
|
| void | set (bool a, bool b, bool c, bool d, bool e) |
| | 单独设置每个级别的开关。
|
| | Logging (std::ostream &os=std::clog, bool cf=false, Level lvl=Level::INFO) |
| | 构造 Logging 对象。
|
| template<class... Args> |
| void | debug (const Args &...args) |
| | 输出 DEBUG 级别日志。
|
| template<class... Args> |
| void | info (const Args &...args) |
| | 输出 INFO 级别日志。
|
| template<class... Args> |
| void | warn (const Args &...args) |
| | 输出 WARN 级别日志。
|
| template<class... Args> |
| void | error (const Args &...args) |
| | 输出 ERROR 级别日志。
|
| template<class... Args> |
| void | fatal (const Args &...args) |
| | 输出 FATAL 级别日志并抛出 fatal_logging 异常。
|
日志记录器,支持多级别、颜色输出和自动时间戳。
使用 Output 类进行格式化输出,可设置最低日志级别或单独控制每个级别的开关。 FATAL 级别会抛出 fatal_logging 异常。
◆ Level
日志级别枚举。
| Enumerator |
|---|
| DEBUG | |
| INFO | |
| WARN | |
| ERROR | |
| FATAL | |
◆ Logging()
| console::Logging::Logging |
( |
std::ostream & | os = std::clog, |
|
|
bool | cf = false, |
|
|
Level | lvl = Level::INFO ) |
|
inline |
构造 Logging 对象。
- Parameters
-
| os | 输出流,默认为 std::cout。 |
| cf | 是否启用颜色,默认 false。 |
| lvl | 最低日志级别,默认 INFO。 |
◆ debug()
template<class... Args>
| void console::Logging::debug |
( |
const Args &... | args | ) |
|
|
inline |
输出 DEBUG 级别日志。
- Template Parameters
-
- Parameters
-
| args | 要输出的内容(可多个,自动转换为字符串)。 |
◆ error()
template<class... Args>
| void console::Logging::error |
( |
const Args &... | args | ) |
|
|
inline |
输出 ERROR 级别日志。
- Template Parameters
-
- Parameters
-
◆ fatal()
template<class... Args>
| void console::Logging::fatal |
( |
const Args &... | args | ) |
|
|
inline |
输出 FATAL 级别日志并抛出 fatal_logging 异常。
- Template Parameters
-
- Parameters
-
- Exceptions
-
◆ info()
template<class... Args>
| void console::Logging::info |
( |
const Args &... | args | ) |
|
|
inline |
输出 INFO 级别日志。
- Template Parameters
-
- Parameters
-
◆ set() [1/2]
| void console::Logging::set |
( |
bool | a, |
|
|
bool | b, |
|
|
bool | c, |
|
|
bool | d, |
|
|
bool | e ) |
|
inline |
单独设置每个级别的开关。
- Parameters
-
| a | DEBUG 开关 |
| b | INFO 开关 |
| c | WARN 开关 |
| d | ERROR 开关 |
| e | FATAL 开关 |
◆ set() [2/2]
| void console::Logging::set |
( |
Level | minLevel | ) |
|
|
inline |
设置最低日志级别(低于该级别的日志将被忽略)。
- Parameters
-
◆ warn()
template<class... Args>
| void console::Logging::warn |
( |
const Args &... | args | ) |
|
|
inline |
输出 WARN 级别日志。
- Template Parameters
-
- Parameters
-
◆ logger
The documentation for this class was generated from the following file: