diff options
Diffstat (limited to 'log.h')
-rw-r--r-- | log.h | 29 |
1 files changed, 17 insertions, 12 deletions
@@ -16,18 +16,23 @@ // -- LOGGER MACROS DETAILS ---------------------------------------------------- -#define LOG(log_, lvl, fmt, ...) \ - do { \ - struct fmt_str_must_be_str_literal { \ - constexpr fmt_str_must_be_str_literal(const char* ptr) : ptr{ptr} {} \ - const char* ptr; \ - }; \ - /* Check if FMT is a string literal, construction fails otherwise. */ \ - constexpr fmt_str_must_be_str_literal _{fmt}; \ - (void)_; \ - \ - if (logging::log_level::lvl <= (log_)->get_level()) \ - (log_)->template log<logging::log_level::lvl>(fmt, ##__VA_ARGS__); \ +#define LOG(log_, lvl, fmt, ...) \ + do { \ + struct fmt_str_must_be_str_literal { \ + constexpr fmt_str_must_be_str_literal(const char* ptr) : ptr{ptr} {} \ + const char* ptr; \ + }; \ + /* Check if FMT is a string literal, construction fails otherwise. */ \ + constexpr fmt_str_must_be_str_literal _{fmt}; \ + (void)_; \ + \ + int lint_fmt_string(const char*, ...) \ + __attribute__((format(printf, 1, 2))); \ + /* Check fmt args against fmt string and warn if -Wformat is enabled. */ \ + (void)sizeof(lint_fmt_string(fmt, ##__VA_ARGS__)); \ + \ + if (logging::log_level::lvl <= (log_)->get_level()) \ + (log_)->template log<logging::log_level::lvl>(fmt, ##__VA_ARGS__); \ } while (0) namespace logging { |