From: Michal Privoznik <mpriv...@redhat.com>

Signed-off-by: Michal Privoznik <mpriv...@redhat.com>
---
 tools/nss/libvirt_nss_log.c | 7 ++++++-
 tools/nss/libvirt_nss_log.h | 7 ++++---
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/tools/nss/libvirt_nss_log.c b/tools/nss/libvirt_nss_log.c
index 9a28a91800..04fc049376 100644
--- a/tools/nss/libvirt_nss_log.c
+++ b/tools/nss/libvirt_nss_log.c
@@ -46,6 +46,7 @@ nssLogPriorityToString(nssLogPriority prio)
 
 void
 nssLog(nssLogPriority prio,
+       const char *filename,
        const char *func,
        int linenr,
        const char *fmt, ...)
@@ -58,7 +59,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);
diff --git a/tools/nss/libvirt_nss_log.h b/tools/nss/libvirt_nss_log.h
index 25926fb6de..60696c7b08 100644
--- a/tools/nss/libvirt_nss_log.h
+++ b/tools/nss/libvirt_nss_log.h
@@ -26,15 +26,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)));
-- 
2.49.0

Reply via email to