diff options
author | Luke T. Shumaker <lukeshu@lukeshu.com> | 2025-05-15 15:55:12 -0600 |
---|---|---|
committer | Luke T. Shumaker <lukeshu@lukeshu.com> | 2025-05-15 15:55:12 -0600 |
commit | 18ddce6270391e5c1924394f8b5d8079ad73289e (patch) | |
tree | 6b647d225665cd4fb2733a57bdfa5f0e96692995 /libmisc/log.c | |
parent | 811d9700e1414dae3357361b3ca565f673f63b08 (diff) | |
parent | e38a2d29292ad3fad64729ef958ff07e3bca02cf (diff) |
Merge branch 'lukeshu/simple-call-graph'
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", |