aboutsummaryrefslogtreecommitdiff
path: root/src/utils/dbg_log.h
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2025-04-08 15:16:21 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2025-04-08 15:16:21 +0200
commite4f356b9592599ad91aac34bf2265c9bcdfbb81f (patch)
tree5a95908f9cb9cf5ad7d7802661e1d0c3bc2a0e3a /src/utils/dbg_log.h
parentc5a6ff0443fc9e5e890fe72cb13ea78d4fe2bbcb (diff)
downloadnissy-core-e4f356b9592599ad91aac34bf2265c9bcdfbb81f.tar.gz
nissy-core-e4f356b9592599ad91aac34bf2265c9bcdfbb81f.zip
Some minor changes to the interface.
- Simplified logger to accept only a string, not a variadic list of args like printf(). This can still use some improvement, but now it is easier to use from other languages. - Fixed some misuses of the logger (wrong types etc) - Renamed some constants - Fixed some typos in comments.
Diffstat (limited to 'src/utils/dbg_log.h')
-rw-r--r--src/utils/dbg_log.h21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/utils/dbg_log.h b/src/utils/dbg_log.h
index f9b1d8a..c30993a 100644
--- a/src/utils/dbg_log.h
+++ b/src/utils/dbg_log.h
@@ -1,6 +1,23 @@
1void (*nissy_log)(const char *, ...); 1#include <stdio.h>
2 2
3#define LOG(...) if (nissy_log != NULL) nissy_log(__VA_ARGS__); 3void (*nissy_log)(const char *);
4void write_wrapper(void (*)(const char *), const char *, ...);
5
6void
7write_wrapper(void (*write)(const char *), const char *str, ...)
8{
9 static const size_t len = 1000;
10 char message[len];
11 va_list args;
12
13 va_start(args, str);
14 sprintf(message, str, args);
15 va_end(args);
16
17 write(message);
18}
19
20#define LOG(...) if (nissy_log != NULL) write_wrapper(nissy_log, __VA_ARGS__);
4 21
5#ifdef DEBUG 22#ifdef DEBUG
6#define STATIC 23#define STATIC

Generated with cgit - Back to sebastiano.tronto.net