[PATCH 09/12] Add a JSON properties parameter to virLog{, V}Message

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



... and update all users.  No change in functionality, the parameter
will be used in later patches.

Signed-off-by: Miloslav Trmač <mitr@xxxxxxxxxx>
---
 src/uml/uml_conf.c   |  2 +-
 src/util/logging.c   | 13 +++++++++----
 src/util/logging.h   | 17 +++++++++--------
 src/util/viraudit.c  |  4 ++--
 src/util/virterror.c |  2 +-
 5 files changed, 22 insertions(+), 16 deletions(-)

diff --git a/src/uml/uml_conf.c b/src/uml/uml_conf.c
index 410f3e2..6ad7a7b 100644
--- a/src/uml/uml_conf.c
+++ b/src/uml/uml_conf.c
@@ -53,7 +53,7 @@
 #define VIR_FROM_THIS VIR_FROM_UML
 
 #define umlLog(level, msg, ...)                                     \
-        virLogMessage(__FILE__, level, 0, msg, __VA_ARGS__)
+        virLogMessage(__FILE__, level, NULL, 0, msg, __VA_ARGS__)
 
 
 static int umlDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED)
diff --git a/src/util/logging.c b/src/util/logging.c
index 97431b2..feef711 100644
--- a/src/util/logging.c
+++ b/src/util/logging.c
@@ -663,6 +663,7 @@ virLogVersionString(const char **rawmsg, char **msg)
  * @priority: the priority level
  * @funcname: the function emitting the (debug) message
  * @linenr: line where the message was emitted
+ * @properties: additional JSON properties to add to the log object, or NULL
  * @flags: extra flags, 1 if coming from the error handler
  * @fmt: the string format
  * @...: the arguments
@@ -671,11 +672,13 @@ virLogVersionString(const char **rawmsg, char **msg)
  * the message may be stored, sent to output or just discarded
  */
 void virLogMessage(const char *category, int priority, const char *funcname,
-                   long long linenr, unsigned int flags, const char *fmt, ...)
+                   long long linenr, virJSONObjectPtr properties,
+                   unsigned int flags, const char *fmt, ...)
 {
     va_list ap;
     va_start(ap, fmt);
-    virLogVMessage(category, priority, funcname, linenr, flags, fmt, ap);
+    virLogVMessage(category, priority, funcname, linenr, properties, flags, fmt,
+                   ap);
     va_end(ap);
 }
 
@@ -685,6 +688,7 @@ void virLogMessage(const char *category, int priority, const char *funcname,
  * @priority: the priority level
  * @funcname: the function emitting the (debug) message
  * @linenr: line where the message was emitted
+ * @properties: additional JSON properties to add to the log object, or NULL
  * @flags: extra flags, 1 if coming from the error handler
  * @fmt: the string format
  * @vargs: format args
@@ -693,8 +697,9 @@ void virLogMessage(const char *category, int priority, const char *funcname,
  * the message may be stored, sent to output or just discarded
  */
 void virLogVMessage(const char *category, int priority, const char *funcname,
-                    long long linenr, unsigned int flags, const char *fmt,
-                    va_list vargs)
+                    long long linenr,
+                    virJSONObjectPtr properties ATTRIBUTE_UNUSED,
+                    unsigned int flags, const char *fmt, va_list vargs)
 {
     static bool logVersionStderr = true;
     char *str = NULL;
diff --git a/src/util/logging.h b/src/util/logging.h
index a66f5dc..14b7b7c 100644
--- a/src/util/logging.h
+++ b/src/util/logging.h
@@ -24,6 +24,7 @@
 
 # include "internal.h"
 # include "buf.h"
+# include "json.h"
 
 /*
  * If configured with --enable-debug=yes then library calls
@@ -32,7 +33,7 @@
  */
 # ifdef ENABLE_DEBUG
 #  define VIR_DEBUG_INT(category, f, l, ...)                            \
-    virLogMessage(category, VIR_LOG_DEBUG, f, l, 0, __VA_ARGS__)
+    virLogMessage(category, VIR_LOG_DEBUG, f, l, NULL, 0, __VA_ARGS__)
 # else
 /**
  * virLogEatParams:
@@ -49,11 +50,11 @@ static inline void virLogEatParams(const char *unused, ...)
 # endif /* !ENABLE_DEBUG */
 
 # define VIR_INFO_INT(category, f, l, ...)                              \
-    virLogMessage(category, VIR_LOG_INFO, f, l, 0, __VA_ARGS__)
+    virLogMessage(category, VIR_LOG_INFO, f, l, NULL, 0, __VA_ARGS__)
 # define VIR_WARN_INT(category, f, l, ...)                              \
-    virLogMessage(category, VIR_LOG_WARN, f, l, 0, __VA_ARGS__)
+    virLogMessage(category, VIR_LOG_WARN, f, l, NULL, 0, __VA_ARGS__)
 # define VIR_ERROR_INT(category, f, l, ...)                             \
-    virLogMessage(category, VIR_LOG_ERROR, f, l, 0, __VA_ARGS__)
+    virLogMessage(category, VIR_LOG_ERROR, f, l, NULL, 0, __VA_ARGS__)
 
 # define VIR_DEBUG(...)                                                 \
         VIR_DEBUG_INT("file." __FILE__, __func__, __LINE__, __VA_ARGS__)
@@ -141,13 +142,13 @@ extern int virLogParseFilters(const char *filters);
 extern int virLogParseOutputs(const char *output);
 extern void virLogMessage(const char *category, int priority,
                           const char *funcname, long long linenr,
-                          unsigned int flags,
-                          const char *fmt, ...) ATTRIBUTE_FMT_PRINTF(6, 7);
+                          virJSONObjectPtr properties, unsigned int flags,
+                          const char *fmt, ...) ATTRIBUTE_FMT_PRINTF(7, 8);
 extern void virLogVMessage(const char *category, int priority,
                            const char *funcname, long long linenr,
-                           unsigned int flags,
+                           virJSONObjectPtr properties, unsigned int flags,
                            const char *fmt,
-                           va_list vargs) ATTRIBUTE_FMT_PRINTF(6, 0);
+                           va_list vargs) ATTRIBUTE_FMT_PRINTF(7, 0);
 extern int virLogSetBufferSize(int size);
 extern void virLogEmergencyDumpAll(int signum);
 #endif
diff --git a/src/util/viraudit.c b/src/util/viraudit.c
index 691d2f1..9437155 100644
--- a/src/util/viraudit.c
+++ b/src/util/viraudit.c
@@ -103,10 +103,10 @@ void virAuditSend(const char *file ATTRIBUTE_UNUSED, const char *func,
 
     if (auditlog && str) {
         if (success)
-            virLogMessage("audit", VIR_LOG_INFO, func, linenr, 0,
+            virLogMessage("audit", VIR_LOG_INFO, func, linenr, NULL, 0,
                           "success=yes %s", str);
         else
-            virLogMessage("audit", VIR_LOG_WARN, func, linenr, 0,
+            virLogMessage("audit", VIR_LOG_WARN, func, linenr, NULL, 0,
                           "success=no %s", str);
     }
 
diff --git a/src/util/virterror.c b/src/util/virterror.c
index 7caa69e..f93b9f6 100644
--- a/src/util/virterror.c
+++ b/src/util/virterror.c
@@ -677,7 +677,7 @@ virRaiseErrorFull(const char *filename ATTRIBUTE_UNUSED,
     if (virErrorLogPriorityFilter)
         priority = virErrorLogPriorityFilter(to, priority);
     virLogMessage(filename, priority,
-                  funcname, linenr,
+                  funcname, linenr, NULL,
                   virErrorLogPriorityFilter ? 0 : 1,
                   "%s", str);
 
-- 
1.7.11.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]