From 84bdfa4a23f5b8daa7921541b007518bc634be0f Mon Sep 17 00:00:00 2001 From: 3gg <3gg@shellblade.net> Date: Mon, 12 Feb 2024 17:56:36 -0800 Subject: Use stderr for LOGE. --- log/include/log/log.h | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'log') 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 @@ #pragma once -// Current implementation assumes a posix environment. - #include -typedef enum { LogDebug, LogInfo, LogWarning, LogError } LogLevel; - -#define LOG(tag, ...) \ - { \ - printf("[%s] %s:%d: ", #tag, __FILE__, __LINE__); \ - printf(__VA_ARGS__); \ - printf("\n"); \ +#define LOG(channel, tag, ...) \ + { \ + fprintf(channel, "[%s] %s:%d: ", #tag, __FILE__, __LINE__); \ + fprintf(channel, __VA_ARGS__); \ + fprintf(channel, "\n"); \ } -#define LOGD(...) LOG(DEBUG, __VA_ARGS__) -#define LOGI(...) LOG(INFO, __VA_ARGS__) -#define LOGW(...) LOG(WARN, __VA_ARGS__) -#define LOGE(...) LOG(ERROR, __VA_ARGS__) +#define LOGD(...) LOG(stdout, DEBUG, __VA_ARGS__) +#define LOGI(...) LOG(stdout, INFO, __VA_ARGS__) +#define LOGW(...) LOG(stdout, WARN, __VA_ARGS__) +#define LOGE(...) LOG(stderr, ERROR, __VA_ARGS__) -- cgit v1.2.3