aboutsummaryrefslogtreecommitdiff
path: root/src/log.c
diff options
context:
space:
mode:
authorFederico Angelilli <code@fedang.net>2025-04-14 20:02:53 +0200
committerFederico Angelilli <code@fedang.net>2025-04-14 22:12:58 +0200
commitefdf4a4883937c8a2fad278fbd4ffc207ef981dc (patch)
tree061e90f703ebd2b447e9b12d39c5868a972ceb4a /src/log.c
parentdc9e9c06421eb9156baf425ac14ec8f50cb8b5ae (diff)
Update logging
Diffstat (limited to 'src/log.c')
-rw-r--r--src/log.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/log.c b/src/log.c
new file mode 100644
index 0000000..b41c0ab
--- /dev/null
+++ b/src/log.c
@@ -0,0 +1,37 @@
+#ifdef _RELEASE
+
+#define ANY_LOG_FORMAT_BEFORE(stream, level, context, module, func) \
+ fprintf(stream, "[%s%s%s%s%s%s%s] %s%s%s: ", \
+ ANY_LOG_COLOR_GET(ANY_LOG_COLOR_CONTEXT), context, ANY_LOG_COLOR_GET(ANY_LOG_COLOR_RESET), *context ? " " : "", \
+ ANY_LOG_COLOR_GET(ANY_LOG_COLOR_MODULE), *func ? func : module, ANY_LOG_COLOR_GET(ANY_LOG_COLOR_RESET), \
+ ANY_LOG_COLOR_GET(level), any_log_level_strings[level], ANY_LOG_COLOR_GET(ANY_LOG_COLOR_RESET))
+
+#define ANY_LOG_VALUE_BEFORE(stream, level, context, module, func, message) \
+ fprintf(stream, "[%s%s%s%s%s%s%s] %s%s%s: %s [", \
+ ANY_LOG_COLOR_GET(ANY_LOG_COLOR_CONTEXT), context, ANY_LOG_COLOR_GET(ANY_LOG_COLOR_RESET), *context ? " " : "", \
+ ANY_LOG_COLOR_GET(ANY_LOG_COLOR_MODULE), *func ? func : module, ANY_LOG_COLOR_GET(ANY_LOG_COLOR_RESET), \
+ ANY_LOG_COLOR_GET(level), any_log_level_strings[level], ANY_LOG_COLOR_GET(ANY_LOG_COLOR_RESET), message)
+#else
+
+#define ANY_LOG_FORMAT_BEFORE(stream, level, context, module, func) \
+ fprintf(stream, "[%s%s%s%s%s%s%s%s%s%s%s] %s%s%s: ", \
+ ANY_LOG_COLOR_GET(ANY_LOG_COLOR_CONTEXT), context, ANY_LOG_COLOR_GET(ANY_LOG_COLOR_RESET), *context ? " " : "", \
+ ANY_LOG_COLOR_GET(ANY_LOG_COLOR_MODULE), module, ANY_LOG_COLOR_GET(ANY_LOG_COLOR_RESET), *func ? " " : "", \
+ ANY_LOG_COLOR_GET(ANY_LOG_COLOR_FUNC), func, ANY_LOG_COLOR_GET(ANY_LOG_COLOR_RESET), \
+ ANY_LOG_COLOR_GET(level), any_log_level_strings[level], ANY_LOG_COLOR_GET(ANY_LOG_COLOR_RESET))
+
+#define ANY_LOG_VALUE_BEFORE(stream, level, context, module, func, message) \
+ fprintf(stream, "[%s%s%s%s%s%s%s%s%s%s%s] %s%s%s: %s [", \
+ ANY_LOG_COLOR_GET(ANY_LOG_COLOR_CONTEXT), context, ANY_LOG_COLOR_GET(ANY_LOG_COLOR_RESET), *context ? " " : "", \
+ ANY_LOG_COLOR_GET(ANY_LOG_COLOR_MODULE), module, ANY_LOG_COLOR_GET(ANY_LOG_COLOR_RESET), *func ? " " : "", \
+ ANY_LOG_COLOR_GET(ANY_LOG_COLOR_FUNC), func, ANY_LOG_COLOR_GET(ANY_LOG_COLOR_RESET), \
+ ANY_LOG_COLOR_GET(level), any_log_level_strings[level], ANY_LOG_COLOR_GET(ANY_LOG_COLOR_RESET), message)
+#endif
+
+#define ANY_LOG_VALUE_STRING(stream, key, value) \
+ fprintf(stream, "%s=\"%s\"", key, value ? value : "(null)")
+
+#define ANY_LOG_COLOR_CONTEXT_DEFAULT "\x1b[34m"
+
+#define ANY_LOG_IMPLEMENT
+#include "log.h"