spdlog 是一个日志库,直接引用头文件即可使用,速度快,异步打印日志。
对应的git地址 spdloggit地址
对应的目录

把上面划线的文件夹引入到自己的工程中,即可使用spdlog
下面是使用例子
            
            
              cpp
              
              
            
          
             inline static void create_logging(const std::string& dir) 
    {
        spdlog::init_thread_pool(8192 * 2, 1); // 16k
        std::shared_ptr<spdlog::logger> l;
        l = spdlog::create_async_nb<spdlog::sinks::rotating_file_sink_mt>
                ("async_file_logger", dir, 1024 * 1024 * 10, 5);
        // 日志级别从低到高 trace, debug, info, warn, err, critical, off, n_levels
        l->flush_on(spdlog::level::info);//warn
        l->set_pattern("[%Y-%m-%d %T.%e][tid:%t  %s:%#] [%l] %v"); //设置信息格式
        spdlog::flush_every(std::chrono::seconds(3));
        spdlog::set_default_logger(l);
    }
    int main()
    {
    	std::string path = "./log.txt";
    	create_logging(path); //创建log文件
    	SPDLOG_ERROR(u8"log文件 error 信息{}", path.c_str()); //打印error类信息
    	SPDLOG_INFO(u8"log文件 info 信息{}", path.c_str());
    	return 0;
    }