diff options
| author | Ethan Werner <mail@ethanwerner.com> | 2026-10-10 20:55:33 +0000 |
|---|---|---|
| committer | Ethan Werner <mail@ethanwerner.com> | 2026-10-10 20:56:50 +0000 |
| commit | f8423ebea413605b42de23f5dd06c5479d3fa1dd (patch) | |
| tree | 2612a5eb026c59e7aae01f10a1cf62f2ee43042c /src/verbose.h | |
Diffstat (limited to 'src/verbose.h')
| -rw-r--r-- | src/verbose.h | 35 |
1 files changed, 35 insertions, 0 deletions
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 |