diff options
author | 3gg <3gg@shellblade.net> | 2024-02-25 15:11:44 -0800 |
---|---|---|
committer | 3gg <3gg@shellblade.net> | 2024-02-25 15:11:44 -0800 |
commit | 3b3c2c14a1eda5894d5db27bbaf4dd5f9a8c67db (patch) | |
tree | 21aee6e640b8d90e6e75a316c70ff9bd8f61d121 /log | |
parent | 9f0923f85d731892e7b58d959d93fdf3c0333096 (diff) |
Better log macro.
Diffstat (limited to 'log')
-rw-r--r-- | log/include/log/log.h | 18 |
1 files 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 @@ | |||
2 | 2 | ||
3 | #include <stdio.h> | 3 | #include <stdio.h> |
4 | 4 | ||
5 | #define LOG(channel, tag, ...) \ | 5 | #define LOG(channel, tag, format, ...) \ |
6 | { \ | 6 | { \ |
7 | fprintf(channel, "[%s] %s:%d: ", #tag, __FILE__, __LINE__); \ | 7 | fprintf( \ |
8 | fprintf(channel, __VA_ARGS__); \ | 8 | channel, "[%s] %s:%d " format "\n", #tag, __FILE__, \ |
9 | fprintf(channel, "\n"); \ | 9 | __LINE__ __VA_OPT__(, ) __VA_ARGS__); \ |
10 | } | 10 | } |
11 | 11 | ||
12 | #define LOGD(...) LOG(stdout, DEBUG, __VA_ARGS__) | 12 | #define LOGD(format, ...) LOG(stdout, DEBUG, format, __VA_ARGS__) |
13 | #define LOGI(...) LOG(stdout, INFO, __VA_ARGS__) | 13 | #define LOGI(format, ...) LOG(stdout, INFO, format, __VA_ARGS__) |
14 | #define LOGW(...) LOG(stdout, WARN, __VA_ARGS__) | 14 | #define LOGW(format, ...) LOG(stdout, WARN, format, __VA_ARGS__) |
15 | #define LOGE(...) LOG(stderr, ERROR, __VA_ARGS__) | 15 | #define LOGE(format, ...) LOG(stderr, ERROR, format, __VA_ARGS__) |