summaryrefslogtreecommitdiffstats
path: root/src/verbose.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/verbose.h')
-rw-r--r--src/verbose.h35
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