From f01b89b599d40df5d6c127310b0030cd41c8dc85 Mon Sep 17 00:00:00 2001 From: "Luke T. Shumaker" Date: Tue, 13 May 2025 18:46:08 -0600 Subject: libmisc: log.h: Add support for libmisc/fmt.h printing --- libmisc/log.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'libmisc/log.c') 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 /* for static_assert() */ +#include +#include + +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", -- cgit v1.2.3-2-g168b