|
Console Library 4.7.0
A header-only library that makes C++ simple
|
提供带颜色和级别的日志记录功能。 More...
#include <cstdint>#include <sstream>#include "output.h"#include "colorful.h"#include "time.h"#include "strpp.h"#include "csexc.h"#include "literals.h"Go to the source code of this file.
Classes | |
| class | console::Logging |
| 日志记录器,支持多级别、颜色输出和自动时间戳。 More... | |
Namespaces | |
| namespace | console |
| 本库所有组件所在的顶层命名空间。 | |
Enumerations | |
| enum class | Level : int8_t { DEBUG , INFO , WARN , ERROR , FATAL } |
| 日志级别枚举。 More... | |
Functions | |
| class console::Logging | console::logger (std::clog, true, Logging::Level::INFO) |
| 全局默认 logger 实例,启用颜色,级别 INFO。 | |
| 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 异常。 | |
提供带颜色和级别的日志记录功能。
包含 Logging 类,支持 DEBUG、INFO、WARN、ERROR、FATAL 五个级别, 可控制输出级别、颜色开关,并自动附加时间戳。全局默认 logger 实例可直接使用。
|
strong |
| void logger::debug | ( | const Args &... | args | ) |
输出 DEBUG 级别日志。
| Args | 可变参数类型。 |
| args | 要输出的内容(可多个,自动转换为字符串)。 |
| void logger::error | ( | const Args &... | args | ) |
输出 ERROR 级别日志。
| Args | 可变参数类型。 |
| args | 要输出的内容。 |
| void logger::fatal | ( | const Args &... | args | ) |
输出 FATAL 级别日志并抛出 fatal_logging 异常。
| Args | 可变参数类型。 |
| args | 要输出的内容。 |
| fatal_logging | 异常,异常消息包含日志内容。 |
| void logger::info | ( | const Args &... | args | ) |
输出 INFO 级别日志。
| Args | 可变参数类型。 |
| args | 要输出的内容。 |
| logger::Logging | ( | std::ostream & | os = std::clog, |
| bool | cf = false, | ||
| Level | lvl = Level::INFO ) |
构造 Logging 对象。
| os | 输出流,默认为 std::cout。 |
| cf | 是否启用颜色,默认 false。 |
| lvl | 最低日志级别,默认 INFO。 |
| void logger::set | ( | bool | a, |
| bool | b, | ||
| bool | c, | ||
| bool | d, | ||
| bool | e ) |
单独设置每个级别的开关。
| a | DEBUG 开关 |
| b | INFO 开关 |
| c | WARN 开关 |
| d | ERROR 开关 |
| e | FATAL 开关 |
| void logger::set | ( | Level | minLevel | ) |
设置最低日志级别(低于该级别的日志将被忽略)。
| minLevel | 最低级别(包含)。 |
| void logger::warn | ( | const Args &... | args | ) |
输出 WARN 级别日志。
| Args | 可变参数类型。 |
| args | 要输出的内容。 |