"test.log");//fileLogger->flush_on(spdlog::level::info);//调用情况下立即刷新日志到磁盘std::string strURL="fengyuzaitu51.cto";intnFirstTime=1;fileLogger->info("Welcome to {0} {1} time!",strURL,nFirstTime);return0;}
spdlog简介 创建Loggers 每个Logger都包含⼀个数组,数组⾥是std::shared_ptr,每次调⽤log时,logger会在每个sink上调⽤sink(log_msg)。sink分为多线程和单线程版本,单线程版本的sink不允许在多线程⾥调⽤ 使⽤factory创建logger //Create and return a shared_ptr to a multithreaded console logger....
SPDLOG_INLINE void registry::flush_on(level::level_enum log_level) { std::lock_guard<std::mutex> lock(logger_map_mutex_); for (auto &l : loggers_) { l.second->flush_on(log_level); } flush_level_ = log_level; } SPDLOG_INLINE void registry::flush_every(std::chrono::seconds int...
spdlog::async_logger::flush() is non-blocking operation. Flush is scheduled for later. I would like to have blocking variant that will wait untill everything that was scheduled for logging untill now is flushed by all sinks. My usecase i...
[%l]%v"); //设置logger的输出格式 //当遇到错误级别以上的立刻刷新到日志 my_logger_->flush_on(spdlog::level::info); } SimLog::SimLog() { } SimLog::~SimLog() { //spdlog::drop_all(); } void SimLog::SetLevel(int level) { spdlog::set_level(static_cast<spdlog::level::level_enum>...
:%#] %v");//设置当出发 err 或更严重的错误时立刻刷新日志到 disklogPtr->flush_on(spdlog::level::trace);//spdlog::flush_every(std::chrono::seconds(3));}autologger(){returnlogPtr;}private:std::shared_ptr<spdlog::logger>logPtr;};#defineINITLOG(path)BaseLog::getInstance()->init(path)...
Periodic flush // periodically flush all *registered* loggers every 3 seconds:// warning: only use if all your loggers are thread safe ("_mt" loggers)spdlog::flush_every(std::chrono::seconds(3)); Stopwatch // Stopwatch support for spdlog#include"spdlog/stopwatch.h"voidstopwatch_example...
//Create a daily logger - a new file is created every day on 2:30am autodaily_logger =spd::daily_logger_mt("daily_logger","logs/daily.txt",2,30); //trigger flush if the log severity is error or higher daily_logger->flush_on(spd::level::err); ...
//trigger flush if the log severity is error or higher 57 daily_logger->flush_on(spd::level::err); astyle Jul 22, 2016 58 daily_logger->info(123.44); 59 60 //Customize msg format for all messages wincolor color formatting support ...
Periodic flush //periodically flush all *registered* loggers every 3 seconds://warning: only use if all your loggers are thread safe!spdlog::flush_every(std::chrono::seconds(3)); Log binary data in hex //many types of std::container<char> types can be used.//ranges are supported too...