diff options
author | Luke T. Shumaker <lukeshu@lukeshu.com> | 2025-05-13 18:46:08 -0600 |
---|---|---|
committer | Luke T. Shumaker <lukeshu@lukeshu.com> | 2025-05-15 14:50:03 -0600 |
commit | f01b89b599d40df5d6c127310b0030cd41c8dc85 (patch) | |
tree | f0f7c2d3746e684ba869784f9f3769ba4e7a1730 /libmisc/log.c | |
parent | 22336fb34f464dc751f86ad552fa1e40f06921ed (diff) |
libmisc: log.h: Add support for libmisc/fmt.h printing
Diffstat (limited to 'libmisc/log.c')
-rw-r--r-- | libmisc/log.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/libmisc/log.c b/libmisc/log.c index be87de6..da4c92e 100644 --- a/libmisc/log.c +++ b/libmisc/log.c @@ -8,6 +8,26 @@ #include <libmisc/assert.h> /* for static_assert() */ +#include <libmisc/log.h> +#include <libmisc/_intercept.h> + +struct log_stdout {}; +LO_IMPLEMENTATION_H(fmt_dest, struct log_stdout, log_stdout); +LO_IMPLEMENTATION_C(fmt_dest, struct log_stdout, log_stdout, static); + +static size_t log_bytes = 0; + +static void log_stdout_putb(struct log_stdout *, uint8_t b) { + __lm_putchar(b); + log_bytes++; +} + +static size_t log_stdout_tell(struct log_stdout *) { + return log_bytes; +} + +lo_interface fmt_dest _log_dest = { .vtable = &_lo_log_stdout_fmt_dest_vtable }; + static const char *byte_strs[] = { "0x00", "0x01", |