| 257 | |
| 258 | template <typename... Args> |
| 259 | static inline void LogPrintf_(const std::string& logging_function, const std::string& source_file, const int source_line, const BCLog::LogFlags flag, const BCLog::Level level, const char* fmt, const Args&... args) |
| 260 | { |
| 261 | if (LogInstance().Enabled()) { |
| 262 | std::string log_msg; |
| 263 | try { |
| 264 | log_msg = tfm::format(fmt, args...); |
| 265 | } catch (tinyformat::format_error& fmterr) { |
| 266 | /* Original format string will have newline so don't add one here */ |
| 267 | log_msg = "Error \"" + std::string(fmterr.what()) + "\" while formatting log message: " + fmt; |
| 268 | } |
| 269 | |
| 270 | const SourceLocation source_location{source_file, source_line}; |
| 271 | LogInstance().LogPrintStr(log_msg, logging_function, source_location, flag, level); |
| 272 | } |
| 273 | } |
| 274 | |
| 275 | |
| 276 | #define LogPrintLevel_(category, level, ...) LogPrintf_(__func__, __FILE__, __LINE__, category, level, __VA_ARGS__) |