allow single arg (#632)

This commit is contained in:
qicosmos 2024-03-18 10:59:40 +08:00 committed by GitHub
parent 06d28e6c04
commit ba4685d98e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 2 deletions

View File

@ -231,7 +231,7 @@ inline void add_appender(std::function<void(std::string_view)> fn) {
#if __has_include(<fmt/format.h>) || __has_include(<format>)
#define ELOGFMT_IMPL0(severity, Id, prefix, format_str, ...) \
#define ELOGFMT_IMPL0(severity, Id, prefix, ...) \
if (!easylog::logger<Id>::instance().check_severity(severity)) { \
; \
} \
@ -239,7 +239,7 @@ inline void add_appender(std::function<void(std::string_view)> fn) {
easylog::logger<Id>::instance() += \
easylog::record_t(std::chrono::system_clock::now(), severity, \
GET_STRING(__FILE__, __LINE__)) \
.format(prefix::format(format_str, __VA_ARGS__)); \
.format(prefix::format(__VA_ARGS__)); \
if constexpr (severity == easylog::Severity::CRITICAL) { \
easylog::flush<Id>(); \
std::exit(EXIT_FAILURE); \

View File

@ -81,6 +81,7 @@ TEST_CASE("test basic") {
ELOG_INFO << buf << ", " << str << ", " << sv << ", " << id;
#if __has_include(<fmt/format.h>) || (__has_include(<format>) && !defined(__APPLE__))
ELOGFMT(INFO, "Hello");
ELOGFMT(INFO, "{} {}", 20, 42);
ELOGFMT(INFO, "it is a long string test {} {}", 42, "fmt");
#endif