#include #include #include #include "notify.h" /* common messaging hook */ /* generic notifier */ static void notify_default_(unsigned int l, const char *fmt, ...) { FILE *f = stderr; va_list ap; const char *level_names[] = { "FATAL", "ERROR", "INFO", "VERBOSE", "DEBUG", "DEBUG_LOCK", }; const size_t levels = sizeof level_names / sizeof *level_names; va_start(ap, fmt); flockfile(f); if (l < levels) { fprintf(f, "%s", level_names[l]); } else { fprintf(f, "[%d] ", l); } vfprintf(f, fmt, ap); funlockfile(f); va_end(ap); } notify_fn_t *notify __attribute__((format(printf, 2, 3))) = notify_default_;