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...
创建rotating file logger 复制代码 //Create rotating file multi-threaded logger #include "spdlog/sinks/rotating_file_sink.h" auto file_logger = spdlog::rotating_logger_mt("file_logger", "logs/mylogfile", 1048576 * 5, 3); ... auto same_logger= spdlog::get("file_logger"); 创建异步logger...
// spdlog #include "spdlog/spdlog.h" #include "spdlog/sinks/rotating_file_sink.h" #include "spdlog/sinks/daily_file_sink.h" #include "spdlog/sinks/stdout_color_sinks.h" #include <iostream> #include <memory> // spd 带行号的打印,同时输出console和文件 #define DEBUG(...) SPDLOG_LOGGER_DE...
#include"spdlog/spdlog.h"#include"spdlog/sinks/rotating_file_sink.h" 创建日志 basic log 不带滚动,日志文件会一直被写入,不断变大。 // Create basic file logger (not rotated)automy_logger = spd::basic_logger_mt("basic_logger","logs/basic-log.txt"); my_logger->info("Some log message")...
#include 'spdlog/sinks/basic_file_sink.h'int main() { auto logger = spdlog::basic_logger_mt('file','my_log.log'); logger->info('hello world'); return 0;} 运行结果如下:创建滚动文件 Logger 可以设置日志文件的大小及数量限定: #include 'spdlog/spdlog.h'#include 'spdlog/sinks/rotating_...
auto logger = spdlog::basic_logger_mt("file","my_log.log"); logger->info("hello world"); return 0; } 运行结果如下: 创建滚动文件 Logger 可以设置日志文件的大小及数量限定: #include "spdlog/spdlog.h" #include "spdlog/sinks/rotating_file_sink.h" ...
代码语言: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...
创建rotating file logger //Create rotating file multi-threaded logger #include "spdlog/sinks/rotating_file_sink.h" auto file_logger = spdlog::rotating_logger_mt("file_logger", "logs/mylogfile", 1048576 * 5, 3); ... auto same_logger= spdlog::get("file_logger"); ...
循环文件 日志文件超过指定大小后,自动生成一个新的;并且只保留最多指定数量的日志文件: 代码语言:javascript 复制 #include"spdlog/sinks/rotating_file_sink.h"void
#include "spdlog/sinks/rotating_file_sink.h" void err_handler_example() { spdlog::set_error_handler([](const std::string& msg){printf("***Custom log error handler, %s***%\n", msg.c_str());}); } int main(int , char *[]) { try...