As promised in previous commit, make NSS modules silent by
default and enable debug printings if LIBVIRT_NSS_DEBUG envvar is
set.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
devices and so on) will not be able to have their hostnames resolved through
it.
+Debugging
+---------
+
+:since:`Since 11.6.0` both NSS modules check for ``LIBVIRT_NSS_DEBUG``
+environment variable¸ which if set to any value turns on printing of debug and
+error messages onto standard error output. This can be useful when debugging
+either of the module.
+
+::
+
+ $ LIBVIRT_NSS_DEBUG=1 getent hosts mydomain
+
+
Alternatives
------------
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
+#include <stdlib.h>
#include "libvirt_nss_log.h"
#include "libvirt_nss.h"
g_autofree char *ebuf = NULL;
va_list ap;
+ if (!getenv(NSS_LOG_ENV_VAR))
+ return;
+
fprintf(stderr, "%s %s:%d : ", nssLogPriorityToString(prio), func, linenr);
va_start(ap, fmt);
#define ERROR(...) \
nssLog(NSS_ERROR, __FUNCTION__, __LINE__, __VA_ARGS__)
+#define NSS_LOG_ENV_VAR "LIBVIRT_NSS_DEBUG"
+
void
nssLog(nssLogPriority prio,
const char *func,