template<typenameT>voidinfo(constT&msg){// 即spdlog::infodefault_logger_raw()->info(msg);}spdlog::logger*default_logger_raw(){returnregistry::instance().get_default_raw();}registry®istry::instance(){staticregistrys_instance;returns_instance;}// 直接用logger的裸指针的原因,spdlog是这么解释...
template <typename T>inline void trace(const T &msg) {default_logger_raw()->trace(msg);}template <typename T>inline void debug(const T &msg) {default_logger_raw()->debug(msg);}template <typename T>inline void info(const T &msg) {default_logger_raw()->info(msg);}template <typename...
SPDLOG_LOGGER_CALL(logger, spdlog::level::trace, __VA_ARGS__) # define SPDLOG_TRACE(...) SPDLOG_LOGGER_TRACE(spdlog::default_logger_raw(), __VA_ARGS__) #else # define SPDLOG_LOGGER_TRACE(logger, ...) (void)0 # define SPDLOG_TRACE(...) (void)0 #endif #if SPDLOG_ACTIVE_LEVEL...
spdlog::set_default_logger(console);// 设置日志输出级别spdlog::set_level(spdlog::level::info);// 设置日志格式spdlog::set_pattern("[%Y-%m-%d %H:%M:%S][%l][%s:%#] %v"); }voidLoggerDrop(){ spdlog::drop_all(); } 4.使用 工程开始需要 LoggerInit(); 用法示例: INFO("Push a cpi ...
logger->flush_on(spdlog::level::warn); 1. 2. 3. 4. 通过宏来同时输出console和文件,注意logger名字和上面的对应。 // spd 带行号的打印,同时输出console和文件 #define DEBUG(...) SPDLOG_LOGGER_DEBUG(spdlog::default_logger_raw(), __VA_ARGS__);SPDLOG_LOGGER_DEBUG(spdlog::get("daily_logger...
{"./spdlog-main.cc", 52, static_cast<const char*>(__FUNCTION__)}, spdlog::level::trace,"Some trace message with param {}", 42);(spdlog::default_logger_raw())->log(spdlog::source_loc{"./spdlog-main.cc", 53, static_cast<const char*>(__FUNCTION__)}, spdlog::level::debug,"...
SPDLOG_LOGGER_DEBUG(spdlog::default_logger_raw(), __VA_ARGS__) Owner gabime commented Oct 9, 2019 Fixed in 9369fe8Contributor Author jwnimmer-tri commented Oct 9, 2019 My attempt went like #define SPDLOG_LOGGER_CALL(logger, level, ...) do { \ spdlog::logger* spdlog_logger_...
auto same_logger= spdlog::get("file_logger"); 1. 2. 3. 4. 5. 创建异步logger #include "spdlog/async.h" void async_example() { // default thread pool settings can be modified *before* creating the async logger: // spdlog::init_thread_pool(8192, 1); // queue with 8k items and...
创建异步logger #include "spdlog/async.h"void async_example(){ // default thread pool settings can be modified *before* creating the async logger:// spdlog::init_thread_pool(8192, 1); // queue with 8k items and 1 backing thread.auto async_file = spdlog::basic_logger_mt<spdlog::async_...
spdlog中定义了一系列Sink类,作为实际上把log输出到指定目标的对象,每一个Sink唯一对应一个log的输出目标(如console、文件、db). 每一个logger包含一个sink列表,每当上层调用logger的log方法写日志时,logger就会调用sink列表中的每一个sink的sink(log_msg)函数,真正往目标中写日志。