]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
nss: Include filename in debug printings
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 19 Jun 2025 08:42:46 +0000 (10:42 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 18 Jul 2025 13:05:41 +0000 (15:05 +0200)
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
tools/nss/libvirt_nss_log.c
tools/nss/libvirt_nss_log.h

index 5365cf7a9640dec5ebe9c8999988a0a56e09d7e0..cf764adafc53b89d8f71ccd062bc7dedb0de8ac2 100644 (file)
@@ -35,6 +35,7 @@ nssLogPriorityToString(nssLogPriority prio)
 
 void
 nssLog(nssLogPriority prio,
+       const char *filename,
        const char *func,
        int linenr,
        const char *fmt, ...)
@@ -47,7 +48,11 @@ nssLog(nssLogPriority prio,
     if (!getenv(NSS_LOG_ENV_VAR))
         return;
 
-    fprintf(stderr, "%s %s:%d : ", nssLogPriorityToString(prio), func, linenr);
+    if ((filename = strrchr(filename, '/')))
+        filename++;
+
+    fprintf(stderr, "%s %s:%s():%d : ",
+            nssLogPriorityToString(prio), NULLSTR(filename), func, linenr);
 
     va_start(ap, fmt);
     vfprintf(stderr, fmt, ap);
index 70a87fec7162fd506cf60066267f9fa22ba937c0..c5bddd0eb5dd8157c87dfa202d85ac7e2531d94e 100644 (file)
@@ -13,15 +13,16 @@ typedef enum {
 } nssLogPriority;
 
 #define DEBUG(...) \
-    nssLog(NSS_DEBUG, __FUNCTION__, __LINE__, __VA_ARGS__)
+    nssLog(NSS_DEBUG, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__)
 
 #define ERROR(...) \
-    nssLog(NSS_ERROR, __FUNCTION__, __LINE__, __VA_ARGS__)
+    nssLog(NSS_ERROR, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__)
 
 #define NSS_LOG_ENV_VAR "LIBVIRT_NSS_DEBUG"
 
 void
 nssLog(nssLogPriority prio,
+       const char *filename,
        const char *func,
        int linenr,
-       const char *fmt, ...) __attribute__ ((format(printf, 4, 5)));
+       const char *fmt, ...) __attribute__ ((format(printf, 5, 6)));