aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author3gg <3gg@shellblade.net>2024-08-28 09:41:36 -0700
committer3gg <3gg@shellblade.net>2024-08-28 09:41:36 -0700
commitf59ede03d8f1d9934823481bcea10c9cfd238c91 (patch)
treedb5081b6f128be8ed785b754e9a6df57748ac410
parent05e2669fd81d33b2ac76b1369a706df90d046517 (diff)
Do not use __VA_OPT__ for now.c
-rw-r--r--log/include/log/log.h21
1 files changed, 17 insertions, 4 deletions
diff --git a/log/include/log/log.h b/log/include/log/log.h
index bd0c20c..c660881 100644
--- a/log/include/log/log.h
+++ b/log/include/log/log.h
@@ -10,14 +10,27 @@
10#undef LOGW 10#undef LOGW
11#undef LOGE 11#undef LOGE
12 12
13#define LOG(channel, tag, format, ...) \ 13// __VA_OPT__ is not available until C2X.
14/*#define LOG(channel, tag, format, ...) \
14 { \ 15 { \
15 fprintf( \ 16 fprintf( \
16 channel, "[%s] %s:%d " format "\n", #tag, __FILE__, \ 17 channel, "[%s] %s:%d " format "\n", #tag, __FILE__, \
17 __LINE__ __VA_OPT__(, ) __VA_ARGS__); \ 18 __LINE__ __VA_OPT__(, ) __VA_ARGS__); \
18 } 19 }*/
19 20
20#define LOGD(format, ...) LOG(stdout, DEBUG, format, __VA_ARGS__) 21/*#define LOGD(format, ...) LOG(stdout, DEBUG, format, __VA_ARGS__)
21#define LOGI(format, ...) LOG(stdout, INFO, format, __VA_ARGS__) 22#define LOGI(format, ...) LOG(stdout, INFO, format, __VA_ARGS__)
22#define LOGW(format, ...) LOG(stdout, WARN, format, __VA_ARGS__) 23#define LOGW(format, ...) LOG(stdout, WARN, format, __VA_ARGS__)
23#define LOGE(format, ...) LOG(stderr, ERROR, format, __VA_ARGS__) 24#define LOGE(format, ...) LOG(stderr, ERROR, format, __VA_ARGS__)*/
25
26#define LOG(channel, tag, ...) \
27 { \
28 fprintf(channel, "[%s] %s:%d ", #tag, __FILE__, __LINE__); \
29 fprintf(channel, __VA_ARGS__); \
30 fprintf(channel, "\n"); \
31 }
32
33#define LOGD(...) LOG(stdout, DEBUG, __VA_ARGS__)
34#define LOGI(...) LOG(stdout, INFO, __VA_ARGS__)
35#define LOGW(...) LOG(stdout, WARN, __VA_ARGS__)
36#define LOGE(...) LOG(stderr, ERROR, __VA_ARGS__)