于是,spdlog提供便捷的创建sink为null_sink的logger对象的方式: // 便捷创建logger对象, 其sink为null_sink_mttemplate<typename Factory = spdlog::synchronous_factory>inlinestd::shared_ptr<logger>null_logger_mt(conststd::string&logger_name){autonull_logger = Factory::template create<sinks::null_sink_mt...
auto db_logger = std::make_shared<spdlog::logger>("db", daily_sink); // 一个日志器使用多个SINK std::vector<spdlog::sink_ptr> sinks; sinks.push_back( std::make_shared<spdlog::sinks::stdout_sink_st>()); sinks.push_back( std::make_shared<spdlog::sinks::daily_file_sink_st>("logf...
auto logger = spdlog::rotating_logger_mt("some_logger_name", "logs/rotating.txt", max_size, max_files); } 每日文件 每天指定时间生成一个新的日志文件: #include "spdlog/sinks/daily_file_sink.h" void daily_example() { // Create a daily logger - a new file is created every day on 2...
具体路径为:/usr/local/include/spdlog/sinks/daily_file_sink.h 其中我使用的可以定点日切的源码为: template<typename Factory = spdlog::synchronous_factory>inline std::shared_ptr<logger> daily_logger_format_mt(const std::string &logger_name, const filename_t &filename, int hour = 0,int minute ...
#include"spdlog/sinks/daily_file_sink.h"..autodaily_logger = spdlog::daily_logger_mt("daily_logger","logs/daily",14,55); will create a thread safe sink which will create a new log file each day on 14:55. Note:Starting from version 1.5.0, spdlog will create, if needed, the folders...
auto my_logger = std::make_shared<spdlog::logger>("mylogger", sink); 1. 2. 使用多个sinks创建logger std::vector<spdlog::sink_ptr>sinks; sinks.push_back(std::make_shared<spdlog::sinks::stdout_sink_st>()); sinks.push_back(std::make_shared<spdlog::sinks::daily_file_sink_st>("log_...
可每日生成日志文件daily_file_sink 每天定时产生文件日志 支持控制台日志输出 可选的异步日志 支持日志输出级别 可自定义日志格式 二.基本使用 1.直接打印日志到console auto console1 = spd::stdout_logger_mt("console1"); console1->error("Some error message with arg{}..", 1); //console2 的module...
Daily files #include"spdlog/sinks/daily_file_sink.h"voiddaily_example() {//Create a daily logger - a new file is created every day at 2:30 amautologger =spdlog::daily_logger_mt("daily_logger","logs/daily.txt",2,30); } Backtrace support ...
sinks.push_back(std::make_shared<spdlog::sinks::daily_file_sink_st>("log_file", 23, 59));auto logger = std::make_shared<spdlog::logger>("mylogger", begin(sinks), end(sinks));spdlog::register_logger(logger);多个⽂件logger共享同⼀个⽂件 auto sharedFileSink = std::make_shared<...
#include "spdlog/sinks/daily_file_sink.h" void daily_example() { // Create a daily logger - a new file is created every day on 2:30am auto daily_logger = spdlog::daily_logger_mt("daily_logger", "logs/daily.txt", 2, 30); } 8.Log binary data in hex 代码语言:javascript 复制 ...