From 3b3c2c14a1eda5894d5db27bbaf4dd5f9a8c67db Mon Sep 17 00:00:00 2001 From: 3gg <3gg@shellblade.net> Date: Sun, 25 Feb 2024 15:11:44 -0800 Subject: Better log macro. --- log/include/log/log.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/log/include/log/log.h b/log/include/log/log.h index 2dc5f9b..8f12b09 100644 --- a/log/include/log/log.h +++ b/log/include/log/log.h @@ -2,14 +2,14 @@ #include -#define LOG(channel, tag, ...) \ - { \ - fprintf(channel, "[%s] %s:%d: ", #tag, __FILE__, __LINE__); \ - fprintf(channel, __VA_ARGS__); \ - fprintf(channel, "\n"); \ +#define LOG(channel, tag, format, ...) \ + { \ + fprintf( \ + channel, "[%s] %s:%d " format "\n", #tag, __FILE__, \ + __LINE__ __VA_OPT__(, ) __VA_ARGS__); \ } -#define LOGD(...) LOG(stdout, DEBUG, __VA_ARGS__) -#define LOGI(...) LOG(stdout, INFO, __VA_ARGS__) -#define LOGW(...) LOG(stdout, WARN, __VA_ARGS__) -#define LOGE(...) LOG(stderr, ERROR, __VA_ARGS__) +#define LOGD(format, ...) LOG(stdout, DEBUG, format, __VA_ARGS__) +#define LOGI(format, ...) LOG(stdout, INFO, format, __VA_ARGS__) +#define LOGW(format, ...) LOG(stdout, WARN, format, __VA_ARGS__) +#define LOGE(format, ...) LOG(stderr, ERROR, format, __VA_ARGS__) -- cgit v1.2.3