+ .hook_evt_addref = hook_evt_addref,
+ .hook_evt_unref = hook_evt_unref
+};
+
+/*******************************************************************************/
+/***** trace the globals *****/
+/*******************************************************************************/
+
+static struct flag global_flags[] = { /* must be sorted by names */
+ { "all", afb_hook_flags_global_all },
+ { "vverbose", afb_hook_flag_global_vverbose },
+};
+
+/* get the global value for flag of 'name' */
+static int get_global_flag(const char *name)
+{
+ return get_flag(name, global_flags, (int)(sizeof global_flags / sizeof *global_flags));
+}
+
+static void hook_global(void *closure, const struct afb_hookid *hookid, const char *action, const char *format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ emit(closure, hookid, "global", "{ss}", format, ap, "action", action);
+ va_end(ap);
+}
+
+static void hook_global_vverbose(void *closure, const struct afb_hookid *hookid, int level, const char *file, int line, const char *function, const char *fmt, va_list args)
+{
+ struct json_object *pos;
+ int len;
+ char *msg;
+ va_list ap;
+
+ pos = NULL;
+ msg = NULL;
+
+ va_copy(ap, args);
+ len = vasprintf(&msg, fmt, ap);
+ va_end(ap);
+
+ if (file)
+ wrap_json_pack(&pos, "{ss si ss*}", "file", file, "line", line, "function", function);
+
+ hook_global(closure, hookid, "vverbose", "{si ss* ss? so*}",
+ "level", level,
+ "type", verbosity_level_name(level),
+ len < 0 ? "format" : "message", len < 0 ? fmt : msg,
+ "position", pos);
+
+ free(msg);
+}
+
+static struct afb_hook_global_itf hook_global_itf = {
+ .hook_global_vverbose = hook_global_vverbose,