diff options
author | 3gg <3gg@shellblade.net> | 2024-02-12 17:56:36 -0800 |
---|---|---|
committer | 3gg <3gg@shellblade.net> | 2024-02-12 17:56:36 -0800 |
commit | 84bdfa4a23f5b8daa7921541b007518bc634be0f (patch) | |
tree | 390a1ca11260720b98f8551240dbb443c461b291 /log/include | |
parent | 46035984dd2f493695d1d3156f9aa6d796ebc9c6 (diff) |
Use stderr for LOGE.
Diffstat (limited to 'log/include')
-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__) |