diff --git a/include/ylt/easylog.hpp b/include/ylt/easylog.hpp index a1e1b434c..e776d7534 100644 --- a/include/ylt/easylog.hpp +++ b/include/ylt/easylog.hpp @@ -19,18 +19,15 @@ #include #include -#ifdef HAS_STD_FORMAT #if __has_include() #include #endif -#endif -#ifdef HAS_FMT_LIB +#if __has_include() #ifndef FMT_HEADER_ONLY #define FMT_HEADER_ONLY #include #endif - #endif #include "easylog/appender.hpp" @@ -232,7 +229,7 @@ inline void add_appender(std::function fn) { ELOGV_IMPL(easylog::Severity::severity, Id, __VA_ARGS__, "\n") #endif -#if defined(HAS_FMT_LIB) || defined(HAS_STD_FORMAT) +#if __has_include() || __has_include() #define ELOGFMT_IMPL0(severity, Id, prefix, format_str, ...) \ if (!easylog::logger::instance().check_severity(severity)) { \ @@ -249,12 +246,12 @@ inline void add_appender(std::function fn) { } \ } -#ifdef HAS_FMT_LIB +#if __has_include() #define ELOGFMT_IMPL(severity, Id, ...) \ ELOGFMT_IMPL0(severity, Id, fmt, __VA_ARGS__) #endif -#ifdef HAS_STD_FORMAT +#if __has_include() #define ELOGFMT_IMPL(severity, Id, ...) \ ELOGFMT_IMPL0(severity, Id, std, __VA_ARGS__) #endif diff --git a/src/easylog/tests/test_easylog.cpp b/src/easylog/tests/test_easylog.cpp index add47f9a9..6cced83b0 100644 --- a/src/easylog/tests/test_easylog.cpp +++ b/src/easylog/tests/test_easylog.cpp @@ -73,7 +73,7 @@ TEST_CASE("test basic") { auto id = std::this_thread::get_id(); ELOG_INFO << buf << ", " << str << ", " << sv << ", " << id; -#if defined(HAS_FMT_LIB) || defined(HAS_STD_FORMAT) +#if __has_include() || (__has_include() && !defined(__APPLE__)) ELOGFMT(INFO, "{} {}", 20, 42); ELOGFMT(INFO, "it is a long string test {} {}", 42, "fmt"); #endif diff --git a/website/docs/zh/easylog/easylog_introduction.md b/website/docs/zh/easylog/easylog_introduction.md index 47f29b293..47c813639 100644 --- a/website/docs/zh/easylog/easylog_introduction.md +++ b/website/docs/zh/easylog/easylog_introduction.md @@ -23,13 +23,8 @@ ELOG(INFO) << "easylog " << 42; // printf输出 ELOGV(INFO, "easylog %d", 42); -// fmt::format 输出 -#if defined(HAS_FMT_LIB) - ELOGFMT(INFO, "easylog {}", 42); -#endif - -// std::format 输出 -#if defined(HAS_STD_FORMAT) +// fmt::format/std::format 输出 +#if __has_include() || __has_include() ELOGFMT(INFO, "easylog {}", 42); #endif ```