// {:p} - don't print the position on each line start.不要在每行开始处打印位置。 // {:n} - don't split the output to lines.不要将输出拆分为行。 #include "spdlog/fmt/bin_to_hex.h" void binary_example() { std::vector<char> buf(80); for (int i = 0; i < 80; i++)...
auto logger = std::make_shared<async_logger>("as", some_sink, tp, async_overflow_policy::overrun_oldest); auto tp2 = std::make_shared(1024, 4); // create pool with queue of 1024 slots and 4 backing threads auto logger2 = std::make_shared<async_logger>("as2", some_sink, tp2, ...
std::unique_ptr<custom_flag_formatter>>;// 由调用者决定patternexplicitpattern_formatter(std::stringpattern, pattern_time_type time_type = pattern_time_type::local,std::stringeol = spdlog::details::os::default
auto tp = std::make_shared(128, 1); auto logger = std::make_shared<async_logger>("as", some_sink, tp, async_overflow_policy::overrun_oldest); auto tp2 = std::make_shared(1024, 4); // create pool with queue of 1024 slots and 4 backing threads auto logger2 = std::make_shared...
// {:p} - don't print the position on each line start. // {:n} - don't split the output into lines. // {:a} - show ASCII if :n is not set. #include "spdlog/fmt/bin_to_hex.h" void binary_example() { auto console = spdlog::get("console"); std::array<char, 80> bu...
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_file", 23, 59));auto logger = std::make_shared<spdlog::logger>("mylogger", begin(sinks), end(sinks)...
public spdlog::sinks::dist_sink<Mutex> { public: filter_off_sink() = default; explicit filter_off_sink(std::vector<std::shared_ptr<sink>> sinks) : spdlog::sinks::dist_sink(std::move(sinks)) {} protected: void sink_it_(const spdlog::details::log_msg& msg) override { if (msg.le...
// many types of std::container<char> types can be used. // ranges are supported too. // format flags: // {:X} - print in uppercase. // {:s} - don't separate each byte with space. // {:p} - don't print the position on each line start. ...
private:std::ofstreamlog_file;ThreadPoollog_pool;mutablestd::mutexlog_mutex;// 保护文件写入操作constchar*toString(LogLevellevel)const{switch(level){caseINFO:return"INFO";caseWARNING:return"WARNING";caseERROR:return"ERROR";default:return"UNKNOWN";}}std::stringcurrentDateTime()const{std::time_tnow...
();auto rotating_sink=std::make_shared<spdlog::sinks::rotating_file_sink_mt>("mylog.txt",1024*1024*10,3);std::vector<spdlog::sink_ptr>sinks{stdout_sink,rotating_sink};auto logger=std::make_shared<spdlog::async_logger>("loggername",sinks.begin(),sinks.end(),spdlog::thread_pool(),...