继续查看rotating_logger_mt,如下: inlinestd::shared_ptr<spdlog::logger>spdlog::rotating_logger_mt(conststd::string& logger_name,constfilename_t& filename,size_tmax_file_size,size_tmax_files){1.returncreate<spdlog::sinks::rotating_file_sink_mt>(logger_name, filename,SPDLOG_FILENAME_T("txt"...
继续查看rotating_logger_mt,如下: inlinestd::shared_ptr<spdlog::logger>spdlog::rotating_logger_mt(conststd::string& logger_name,constfilename_t& filename,size_tmax_file_size,size_tmax_files){1.returncreate<spdlog::sinks::rotating_file_sink_mt>(logger_name, filename,SPDLOG_FILENAME_T("txt"...
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...
1. return create<spdlog::sinks::rotating_file_sink_mt>(logger_name, filename, SPDLOG_FILENAME_T("txt"), max_file_size, max_files);} line: 1, 实际创建对象。create是⼀个模板函数,如下:template <typename Sink, typename... Args> inline std::shared_ptr<spdlog::logger> spdlog::create(...
; // basic_logger_st返回使用basic_file_sink的logger,且单线程版本(非线程安全的) template <typename Factory = spdlog::synchronous_factory> std::shared_ptr<logger> basic_logger_st(...); // rotating_logger_mt返回使用rotating_file_sink的logger,且多线程版本(线程安全的) template <typename Factory...
代码语言:javascript 复制 #include<iostream>#include<cstdio>#include"spdlog/spdlog.h"#include"spdlog/sinks/rotating_file_sink.h"using namespace std;using namespace spdlog;auto rotating_logger=rotating_logger_mt("mylog","logs/rotating.txt",1048576*5,3);intmain(int,char*[]){int a,b;a=5;b...
file_size=1024*1024*100file_sink=spdlog.rotating_file_sink_mt(log_file_path,max_size=file_size,max_files=100)logger=spdlog.RotatingLogger('MmLog',log_file_path,False,file_size,100,False)sinks=[file_sink,console_sink]logger=spdlog.SinkLogger(self.log_name,sinks)logger.set_pattern(pattern="...
//auto file_sink = std::make_shared<spdlog::sinks::basic_file_sink_mt>("logs/multisink.txt", false); auto file_sink = std::make_shared<spdlog::sinks::rotating_file_sink_mt>(logFile, max_size, max_file); file_sink->set_pattern("[%Y-%m-%d %H:%M:%S:%e] [%n] [tid: %t] ...
#include<iostream>#include"spdlog/spdlog.h"#include"spdlog/sinks/rotating_file_sink.h"// support for rotating file loggingintmain(intargc,char*argv[]){try{// create a file rotating logger with 5mb size max and 3 rotated filesautofile_logger=spdlog::rotating_logger_mt("file_logger","myfil...
#include "spdlog/sinks/rotating_file_sink.h"auto max_size = 1048576 * 5; // 5 MBauto max_files = 3;auto logger = spdlog::rotating_logger_mt("my_logger", "my_log.txt", max_size, max_files); 这段代码创建了一个按大小滚动的日志记录器,每个日志文件最大 5MB,最多保留 3 个备份。