简介
该项目是一个基于spdlog封装的logger库,用于打印日志, 兼容printf和std::cout两种打印方式
使用
使用export LOG_LEVEL=n控制日志级别
日志级别
- TRACE: export LOG_LEVEL=0
- DEBUG: export LOG_LEVEL=1
- INFO: export LOG_LEVEL=2
- ERROR:export LOG_LEVEL=3
- OFF: export LOG_LEVEL=5
printf风格打印
LOG_TRACE("This is a Trace message"); LOG_DEBUG("This is a Debug message"); LOG_INFO("This is an Info message"); LOG_WARN("This is a Warning message"); LOG_ERROR("This is an Error message");
std::cout风格打印
LOG(TRACE) << "This is a Trace message"; LOG(DEBUG) << "This is a Debug message"; LOG(INFO) << "This is an Info message"; LOG(WARN) << "This is a Warning message"; LOG(ERROR) << "This is an Error message";
自定义Log宏
- HEADER(LEVEL): 用于控制后续日志的缩进,方便观察调用栈
- FOOTER(LEVEL):与HEADER配对使用
void func2() { HEADER(DEBUG); FOOTER(DEBUG); }