void logger::log_it_(const spdlog::details::log_msg &log_msg, bool log_enabled, bool traceback_enabled) { if (log_enabled) { sink_it_(log_msg); } if (traceback_enabled) { tracer_.push_back(log_msg); } } void logger::sink_it_(const details::log_msg &msg) { for (auto &...
string_view_t fmt, Args &&...args) {boollog_enabled = should_log(lvl);//判断是否需要记录日志(根据日志级别)booltraceback_enabled = tracer_.enabled();//判断是否需要tracebackif(!log_enabled && !traceback_enabled) {return;
// common implementation for after templated public api has been resolvedtemplate<typename... Args>voidlog_(source_loc loc, level::level_enum lvl,string_view_tfmt, Args &&... args){boollog_enabled = should_log(lvl);// 只有优先级不低于指定优先级的log消息, 才被允许记录booltraceback_enabled...
details::log_msglog_msg(loc, name_, lvl,string_view_t(buf.data(), buf.size())); log_it_(log_msg, log_enabled, traceback_enabled); } 首先判断是否需要记录日志should_log(lvl),以及是否需要traceback,如果都不需要则直接返回。判断逻辑是当前log等级是否大于logger的log等级。比如代码开发过成功会...
After a rough reading of the source code, it appears that "traceback_enabled" being false is normal because I did not enable the backtrace feature. The reason for "log_enabled" being false is that in the main function, the global log level is set to debug (set_level(debug)), and lin...
Most use cases don't need the redundant checks of the log+traceback levels. It is only applicable when when SPDLOG_ACTIVE_LEVEL is high enough and one of the args is a costly computation expression In cases that it is relevant, It can be easily solved by wrapping with if(logger->should...
(log_msg,log_enabled,traceback_enabled);}// 5.voidlogger::log_it_(constspdlog::details::log_msg&log_msg,bool log_enabled,bool traceback_enabled){if(log_enabled){sink_it_(log_msg);}if(traceback_enabled){tracer_.push_back(log_msg);}}// 6.voidlogger::sink_it_(constdetails::log_...