aboutsummaryrefslogtreecommitdiff
path: root/log.h
diff options
context:
space:
mode:
Diffstat (limited to 'log.h')
-rw-r--r--log.h29
1 files changed, 17 insertions, 12 deletions
diff --git a/log.h b/log.h
index c0880fb..795bac1 100644
--- a/log.h
+++ b/log.h
@@ -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 {