diff options
Diffstat (limited to 'libmisc/log.c')
-rw-r--r-- | libmisc/log.c | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/libmisc/log.c b/libmisc/log.c index 9bf5366..96e9ca4 100644 --- a/libmisc/log.c +++ b/libmisc/log.c @@ -1,25 +1,32 @@ /* libmisc/log.c - stdio logging * - * Copyright (C) 2024 Luke T. Shumaker <lukeshu@lukeshu.com> + * Copyright (C) 2024-2025 Luke T. Shumaker <lukeshu@lukeshu.com> * SPDX-License-Identifier: AGPL-3.0-or-later */ -#include <stdio.h> /* for vprintf() */ -#include <stdarg.h> /* for va_list, va_start(), va_end() */ +#include <stdint.h> /* for uint{n}_t */ -#include <libmisc/assert.h> +#include <libmisc/assert.h> /* for static_assert() */ -#define LOG_NAME +#include <libmisc/_intercept.h> #include <libmisc/log.h> -int _log_printf(const char *format, ...) { - va_list va; - va_start(va, format); - int ret = vprintf(format, va); - va_end(va); - return ret; +struct log_stdout {}; +LO_IMPLEMENTATION_STATIC(fmt_dest, struct log_stdout, log_stdout); + +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", |