diff options
Diffstat (limited to 'log')
| -rw-r--r-- | log/CMakeLists.txt | 9 | ||||
| -rw-r--r-- | log/README.md | 1 | ||||
| -rw-r--r-- | log/include/log/log.h | 19 | ||||
| -rw-r--r-- | log/src/log.c | 1 |
4 files changed, 30 insertions, 0 deletions
diff --git a/log/CMakeLists.txt b/log/CMakeLists.txt new file mode 100644 index 0000000..490c78c --- /dev/null +++ b/log/CMakeLists.txt | |||
| @@ -0,0 +1,9 @@ | |||
| 1 | cmake_minimum_required(VERSION 3.16) | ||
| 2 | |||
| 3 | add_library(log | ||
| 4 | src/log.c) | ||
| 5 | |||
| 6 | target_include_directories(log PUBLIC | ||
| 7 | include) | ||
| 8 | |||
| 9 | target_compile_options(log PRIVATE -Wall -Wextra) | ||
diff --git a/log/README.md b/log/README.md new file mode 100644 index 0000000..1c70225 --- /dev/null +++ b/log/README.md | |||
| @@ -0,0 +1 @@ | |||
| # Logging Library | |||
diff --git a/log/include/log/log.h b/log/include/log/log.h new file mode 100644 index 0000000..41a83cc --- /dev/null +++ b/log/include/log/log.h | |||
| @@ -0,0 +1,19 @@ | |||
| 1 | #pragma once | ||
| 2 | |||
| 3 | // Current implementation assumes a posix environment. | ||
| 4 | |||
| 5 | #include <stdio.h> | ||
| 6 | |||
| 7 | typedef enum { LogDebug, LogInfo, LogWarning, LogError } LogLevel; | ||
| 8 | |||
| 9 | #define LOG(tag, ...) \ | ||
| 10 | { \ | ||
| 11 | printf("[%s] %s:%d: ", #tag, __FILE__, __LINE__); \ | ||
| 12 | printf(__VA_ARGS__); \ | ||
| 13 | printf("\n"); \ | ||
| 14 | } | ||
| 15 | |||
| 16 | #define LOGD(...) LOG(DEBUG, __VA_ARGS__) | ||
| 17 | #define LOGI(...) LOG(INFO, __VA_ARGS__) | ||
| 18 | #define LOGW(...) LOG(WARN, __VA_ARGS__) | ||
| 19 | #define LOGE(...) LOG(ERROR, __VA_ARGS__) | ||
diff --git a/log/src/log.c b/log/src/log.c new file mode 100644 index 0000000..0e0248e --- /dev/null +++ b/log/src/log.c | |||
| @@ -0,0 +1 @@ | |||
| #include <log/log.h> | |||
