diff options
Diffstat (limited to 'log')
| -rw-r--r-- | log/CMakeLists.txt | 6 | ||||
| -rw-r--r-- | log/include/log/log.h | 23 |
2 files changed, 11 insertions, 18 deletions
diff --git a/log/CMakeLists.txt b/log/CMakeLists.txt index cc103c5..615e200 100644 --- a/log/CMakeLists.txt +++ b/log/CMakeLists.txt | |||
| @@ -1,5 +1,11 @@ | |||
| 1 | cmake_minimum_required(VERSION 3.5) | 1 | cmake_minimum_required(VERSION 3.5) |
| 2 | 2 | ||
| 3 | project(log) | ||
| 4 | |||
| 5 | set(CMAKE_C_STANDARD 23) | ||
| 6 | set(CMAKE_C_STANDARD_REQUIRED On) | ||
| 7 | set(CMAKE_C_EXTENSIONS Off) | ||
| 8 | |||
| 3 | add_library(log | 9 | add_library(log |
| 4 | src/log.c) | 10 | src/log.c) |
| 5 | 11 | ||
diff --git a/log/include/log/log.h b/log/include/log/log.h index c660881..f94ba84 100644 --- a/log/include/log/log.h +++ b/log/include/log/log.h | |||
| @@ -10,24 +10,11 @@ | |||
| 10 | #undef LOGW | 10 | #undef LOGW |
| 11 | #undef LOGE | 11 | #undef LOGE |
| 12 | 12 | ||
| 13 | // __VA_OPT__ is not available until C2X. | 13 | #define LOG(channel, tag, ...) \ |
| 14 | /*#define LOG(channel, tag, format, ...) \ | 14 | { \ |
| 15 | { \ | 15 | fprintf(channel, "[%s] %s:%d", #tag, __FILE__, __LINE__); \ |
| 16 | fprintf( \ | 16 | fprintf(channel, " " __VA_ARGS__); \ |
| 17 | channel, "[%s] %s:%d " format "\n", #tag, __FILE__, \ | 17 | fprintf(channel, "\n"); \ |
| 18 | __LINE__ __VA_OPT__(, ) __VA_ARGS__); \ | ||
| 19 | }*/ | ||
| 20 | |||
| 21 | /*#define LOGD(format, ...) LOG(stdout, DEBUG, format, __VA_ARGS__) | ||
| 22 | #define LOGI(format, ...) LOG(stdout, INFO, format, __VA_ARGS__) | ||
| 23 | #define LOGW(format, ...) LOG(stdout, WARN, 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 | } | 18 | } |
| 32 | 19 | ||
| 33 | #define LOGD(...) LOG(stdout, DEBUG, __VA_ARGS__) | 20 | #define LOGD(...) LOG(stdout, DEBUG, __VA_ARGS__) |
