GetInstance().GetLogger()->log(spdlog::source_loc{__FILE__, __LINE__, SPDLOG_FUNCTION}, level, __VA_ARGS__) #define LogTrace(...) SPDLOG_LOGGER_CALL_(spdlog::level::trace,__VA_ARGS__) #define LogDebug(...) SPDLOG_LOGGER_CALL_(spdlog::level::debug,__VA_ARGS__) #define Log...
template<typename... Args>voidlog(level::level_enum lvl,format_string_t<Args...> fmt, Args &&... args){log(source_loc{}, lvl, fmt,std::forward<Args>(args)...);// source_loc为空} template<typename T>voidlog(level::level_enum lvl,constT &msg){log(source_loc{}, lvl, msg);/...
改代码基于C++17,C++20新增了source_location,可以获取行号,文件名等信息,但是可以使用C++17自己实现一个, 如果编译器支持C++20,可以进行简单改造。 classSourceLocation{public:constexprSourceLocation(constchar*fileName=__builtin_FILE(),constchar*funcName=__builtin_FUNCTION(),std::uint32_tlineNum=__buil...
#include <experimental/source_location> #define SPDLOG_HAVE_EXPERIMENTAL_SOURCE_LOCATION #endifnamespace spdlog { // source location - either initiated from std::source_location or from // std::experimental::source_location or empty struct source_loc { ...
(source_loc loc, level::level_enum lvl, string_view_t fmt, Args &&...args);//字符串格式化后将日志信息封装至details::log_msg结构体中-->voidlogger::log_it_(constspdlog::details::log_msg &log_msg,boollog_enabled,booltraceback_enabled);-->voidlogger::sink_it_(constdetails::log_msg ...
\>\>\> referenced by objects.a(main.cpp.obj):(spdlog::logger::log(spdlog::source_loc, spdlog::level::level_enum, fmt::v10::basic_string_view<cha r>)) >, spdlog::level::level_enum, fmt::v10::basic_string_view<char>)
(spdlog::source_loc{__FILE__,__LINE__,SPDLOG_FUNCTION},level,__VA_ARGS__)#defineLogTrace(...)SPDLOG_LOGGER_CALL_(spdlog::level::trace,__VA_ARGS__)#defineLogDebug(...)SPDLOG_LOGGER_CALL_(spdlog::level::debug,__VA_ARGS__)#defineLogInfo(...)SPDLOG_LOGGER_CALL_(spdlog::level::...
(){returnlogPtr;}private:std::shared_ptr<spdlog::logger>logPtr;};#defineINITLOG(path)BaseLog::getInstance()->init(path)//参见SPDLOG_LOGGER_CALL#defineSPDLOG_BASE(logger,level,...)(logger)->log(spdlog::source_loc{__FILE__,__LINE__,__func__},level,__VA_ARGS__)#defineTRACELOG(.....
voidlog(source_loc loc, level::level_enum lvl,format_string_t<Args...> fmt, Args &&... args); template<typename... Args> voidlog(level::level_enum lvl,format_string_t<Args...> fmt, Args &&... args); // ... template<typename... Args> ...
template<typenameT>voidlog(source_loc loc, level::level_enum lvl,constT &msg) {log(loc, lvl,"{}", msg); }// 因为spdlog::info(num);可以等价为spdlog::info("{}", num);,所以这里加了一个“{}” template<typename... Args>