From f8423ebea413605b42de23f5dd06c5479d3fa1dd Mon Sep 17 00:00:00 2001 From: Ethan Werner Date: Sat, 10 Oct 2026 20:55:33 +0000 Subject: initial commit --- src/verbose.h | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/verbose.h (limited to 'src/verbose.h') diff --git a/src/verbose.h b/src/verbose.h new file mode 100644 index 0000000..35c2002 --- /dev/null +++ b/src/verbose.h @@ -0,0 +1,35 @@ +#ifndef LLSH_VERBOSE_H +#define LLSH_VERBOSE_H + +#include "util.h" + +/* Structured event logging (one JSON object per line) to stderr, + * enabled via --verbose / config. Mirrors verbose.rs. */ + +typedef enum { + VLOG_STR, + VLOG_INT, + VLOG_BOOL, + VLOG_DBL, +} vlog_kind; + +typedef struct { + const char *key; + vlog_kind kind; + const char *s; + long long i; + double d; + bool b; +} vlog_kv; + +#define VLOG_STR(k, v) { (k), VLOG_STR, (v), 0, 0, false } +#define VLOG_INT(k, v) { (k), VLOG_INT, NULL, (long long)(v), 0, false } +#define VLOG_BOOL(k, v) { (k), VLOG_BOOL, NULL, 0, 0, (v) } +#define VLOG_DBL(k, v) { (k), VLOG_DBL, NULL, 0, (v), false } + +void verbose_set(bool on); +bool verbose_enabled(void); +void verbose_set_sink(void (*sink)(const char *line, void *ud), void *ud); +void verbose_log(const char *event, const vlog_kv *kvs, size_t n); + +#endif -- cgit v1.3.1