diff options
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", |