84 int8_t n = int8_t(minLevel);
85 for (
int i = 0; i < n; i++)
87 for (
int i = n; i < 5; i++)
99 void set(
bool a,
bool b,
bool c,
bool d,
bool e)
116 : output(os,
"",
"\n", true),
117 colorful(cf) {
set(lvl); }
124 template <
class... Args>
134 output(
'[',
datetime(),
"] [DEBUG] - ", args...);
143 template <
class... Args>
153 output(
'[',
datetime(),
"] [.INFO] - ", args...);
162 template <
class... Args>
172 output(
'[',
datetime(),
"] [.WARN] - ", args...);
181 template <
class... Args>
191 output(
'[',
datetime(),
"] [ERROR] - ", args...);
201 template <
class... Args>
212 output(
'[',
datetime(),
"] [FATAL] - ", error_info);
void warn(const Args &...args)
输出 WARN 级别日志。
Definition logging.h:163
Logging(std::ostream &os=std::clog, bool cf=false, Level lvl=Level::INFO)
构造 Logging 对象。
Definition logging.h:114
void error(const Args &...args)
输出 ERROR 级别日志。
Definition logging.h:182
void info(const Args &...args)
输出 INFO 级别日志。
Definition logging.h:144
void fatal(const Args &...args)
输出 FATAL 级别日志并抛出 fatal_logging 异常。
Definition logging.h:202
void debug(const Args &...args)
输出 DEBUG 级别日志。
Definition logging.h:125
void set(Level minLevel)
设置最低日志级别(低于该级别的日志将被忽略)。
Definition logging.h:82
Level
日志级别枚举。
Definition logging.h:64
@ FATAL
Definition logging.h:69
@ WARN
Definition logging.h:67
@ INFO
Definition logging.h:66
@ ERROR
Definition logging.h:68
@ DEBUG
Definition logging.h:65
void set(bool a, bool b, bool c, bool d, bool e)
单独设置每个级别的开关。
Definition logging.h:99
表示致命日志错误,通常会导致程序终止。
Definition csexc.h:59
提供控制台颜色和样式修饰的 ANSI 转义序列常量。
定义 console 库使用的自定义异常类层次结构。
std::string uni_to_str(Args &&...args)
将任意多个参数转换为字符串并拼接(无分隔符)。
Definition strpp.h:281
提供自定义字面量运算符,包括字符串字面量、时间字面量和格式化字符串字面量。
const char * BrightRed
亮红色前景
Definition colorful.h:62
const char * BrightBlack
亮黑色(灰)前景
Definition colorful.h:60
const char * BrightYellow
亮黄色前景
Definition colorful.h:66
const char * BrightCyan
亮青色前景
Definition colorful.h:72
const char * BrightMagenta
亮品红前景
Definition colorful.h:70
const char * Reset
重置所有颜色/样式
Definition colorful.h:76
std::string datetime(const std::string &fmt="%Y-%m-%d %H:%M:%S")
获取当前日期时间字符串。
Definition time.h:166
class console::Logging logger(std::clog, true, Logging::Level::INFO)
全局默认 logger 实例,启用颜色,级别 INFO。
提供 STL 容器的格式化输出和灵活的输出控制工具。