+void (*verbose_observer)(int loglevel, const char *file, int line, const char *function, const char *fmt, va_list args);
+
+#define CROP_LOGLEVEL(x) ((x) < Log_Level_Emergency ? Log_Level_Emergency : (x) > Log_Level_Debug ? Log_Level_Debug : (x))
+
+#if defined(VERBOSE_WITH_SYSLOG)
+
+#include <syslog.h>
+
+static void _vverbose_(int loglevel, const char *file, int line, const char *function, const char *fmt, va_list args)
+{
+ char *p;
+
+ if (file == NULL || vasprintf(&p, fmt, args) < 0)
+ vsyslog(loglevel, fmt, args);
+ else {
+ syslog(CROP_LOGLEVEL(loglevel), "%s [%s:%d, function]", p, file, line, function);
+ free(p);
+ }
+}
+
+void verbose_set_name(const char *name, int authority)
+{
+ openlog(name, LOG_PERROR, authority ? LOG_AUTH : LOG_USER);
+}
+
+#elif defined(VERBOSE_WITH_SYSTEMD)
+
+#define SD_JOURNAL_SUPPRESS_LOCATION
+
+#include <systemd/sd-journal.h>
+
+static const char *appname;
+
+static int appauthority;
+
+static void _vverbose_(int loglevel, const char *file, int line, const char *function, const char *fmt, va_list args)
+{
+ char lino[20];
+
+ if (file == NULL) {
+ sd_journal_printv(loglevel, fmt, args);
+ } else {
+ sprintf(lino, "%d", line);
+ sd_journal_printv_with_location(loglevel, file, lino, function, fmt, args);
+ }
+}
+
+void verbose_set_name(const char *name, int authority)
+{
+ appname = name;
+ appauthority = authority;
+}
+
+#else
+
+#include <unistd.h>
+#include <errno.h>
+#include <string.h>
+#include <sys/uio.h>
+#include <pthread.h>
+
+static const char *appname;
+
+static int appauthority;