Merge pull request #306 from daniellimws/new-fmt-macros

logging: Use variadic template instead of FMT_VARIADIC
merge-requests/60/head
bunnei 2018-04-02 22:48:17 +07:00 committed by GitHub
commit b87a588c37
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 5 deletions

@ -146,12 +146,12 @@ void LogMessage(Class log_class, Level log_level, const char* filename, unsigned
PrintColoredMessage(entry); PrintColoredMessage(entry);
} }
void FmtLogMessage(Class log_class, Level log_level, const char* filename, unsigned int line_num, void LogMessage(Class log_class, Level log_level, const char* filename, unsigned int line_num,
const char* function, const char* format, const fmt::ArgList& args) { const char* function, const char* format, const fmt::format_args& args) {
if (filter && !filter->CheckMessage(log_class, log_level)) if (filter && !filter->CheckMessage(log_class, log_level))
return; return;
Entry entry = Entry entry =
CreateEntry(log_class, log_level, filename, line_num, function, fmt::format(format, args)); CreateEntry(log_class, log_level, filename, line_num, function, fmt::vformat(format, args));
PrintColoredMessage(entry); PrintColoredMessage(entry);
} }

@ -104,9 +104,15 @@ void LogMessage(Class log_class, Level log_level, const char* filename, unsigned
#endif #endif
; ;
/// Logs a message to the global logger, using fmt
void LogMessage(Class log_class, Level log_level, const char* filename, unsigned int line_num,
const char* function, const char* format, const fmt::format_args& args);
template <typename... Args>
void FmtLogMessage(Class log_class, Level log_level, const char* filename, unsigned int line_num, void FmtLogMessage(Class log_class, Level log_level, const char* filename, unsigned int line_num,
const char* function, const char* format, const fmt::ArgList& args); const char* function, const char* format, const Args&... args) {
FMT_VARIADIC(void, FmtLogMessage, Class, Level, const char*, unsigned int, const char*, const char*) LogMessage(log_class, log_level, filename, line_num, function, format, fmt::make_args(args...));
}
} // namespace Log } // namespace Log