diff options
-rw-r--r-- | log/include/log/log.h | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/log/include/log/log.h b/log/include/log/log.h index 41a83cc..2dc5f9b 100644 --- a/log/include/log/log.h +++ b/log/include/log/log.h | |||
@@ -1,19 +1,15 @@ | |||
1 | #pragma once | 1 | #pragma once |
2 | 2 | ||
3 | // Current implementation assumes a posix environment. | ||
4 | |||
5 | #include <stdio.h> | 3 | #include <stdio.h> |
6 | 4 | ||
7 | typedef enum { LogDebug, LogInfo, LogWarning, LogError } LogLevel; | 5 | #define LOG(channel, tag, ...) \ |
8 | 6 | { \ | |
9 | #define LOG(tag, ...) \ | 7 | fprintf(channel, "[%s] %s:%d: ", #tag, __FILE__, __LINE__); \ |
10 | { \ | 8 | fprintf(channel, __VA_ARGS__); \ |
11 | printf("[%s] %s:%d: ", #tag, __FILE__, __LINE__); \ | 9 | fprintf(channel, "\n"); \ |
12 | printf(__VA_ARGS__); \ | ||
13 | printf("\n"); \ | ||
14 | } | 10 | } |
15 | 11 | ||
16 | #define LOGD(...) LOG(DEBUG, __VA_ARGS__) | 12 | #define LOGD(...) LOG(stdout, DEBUG, __VA_ARGS__) |
17 | #define LOGI(...) LOG(INFO, __VA_ARGS__) | 13 | #define LOGI(...) LOG(stdout, INFO, __VA_ARGS__) |
18 | #define LOGW(...) LOG(WARN, __VA_ARGS__) | 14 | #define LOGW(...) LOG(stdout, WARN, __VA_ARGS__) |
19 | #define LOGE(...) LOG(ERROR, __VA_ARGS__) | 15 | #define LOGE(...) LOG(stderr, ERROR, __VA_ARGS__) |