[libvirt] [PATCH 10/12] Add a JSON properties parameter to virLogOutputFunc

Miloslav Trmač mitr at redhat.com
Thu Sep 20 18:24:09 UTC 2012


... and update all users.  No change in functionality, the parameter
will be used in the next patch.

Signed-off-by: Miloslav Trmač <mitr at redhat.com>
---
 src/util/logging.c | 20 +++++++++++---------
 src/util/logging.h |  2 ++
 tests/testutils.c  |  1 +
 3 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/src/util/logging.c b/src/util/logging.c
index feef711..987dffc 100644
--- a/src/util/logging.c
+++ b/src/util/logging.c
@@ -104,7 +104,7 @@ static int virLogResetFilters(void);
 static int virLogResetOutputs(void);
 static void virLogOutputToFd(const char *category, int priority,
                              const char *funcname, long long linenr,
-                             const char *timestamp,
+                             const char *timestamp, virJSONObjectPtr properties,
                              unsigned int flags,
                              const char *rawstr, const char *str,
                              void *data);
@@ -697,8 +697,7 @@ 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,
-                    virJSONObjectPtr properties ATTRIBUTE_UNUSED,
+                    long long linenr, virJSONObjectPtr properties,
                     unsigned int flags, const char *fmt, va_list vargs)
 {
     static bool logVersionStderr = true;
@@ -768,13 +767,13 @@ void virLogVMessage(const char *category, int priority, const char *funcname,
                 if (virLogVersionString(&rawver, &ver) >= 0)
                     virLogOutputs[i].f(category, VIR_LOG_INFO,
                                        __func__, __LINE__,
-                                       timestamp, 0, rawver, ver,
+                                       timestamp, NULL, 0, rawver, ver,
                                        virLogOutputs[i].data);
                 VIR_FREE(ver);
                 virLogOutputs[i].logVersion = false;
             }
             virLogOutputs[i].f(category, priority, funcname, linenr,
-                               timestamp, filterflags,
+                               timestamp, properties, filterflags,
                                str, msg, virLogOutputs[i].data);
         }
     }
@@ -785,13 +784,13 @@ void virLogVMessage(const char *category, int priority, const char *funcname,
             if (virLogVersionString(&rawver, &ver) >= 0)
                 virLogOutputToFd(category, VIR_LOG_INFO,
                                  __func__, __LINE__,
-                                 timestamp, 0, rawver, ver,
+                                 timestamp, NULL, 0, rawver, ver,
                                  (void *) STDERR_FILENO);
             VIR_FREE(ver);
             logVersionStderr = false;
         }
         virLogOutputToFd(category, priority, funcname, linenr,
-                         timestamp, filterflags,
+                         timestamp, properties, filterflags,
                          str, msg, (void *) STDERR_FILENO);
     }
     virLogUnlock();
@@ -827,6 +826,7 @@ static void virLogOutputToFd(const char *category ATTRIBUTE_UNUSED,
                              const char *funcname ATTRIBUTE_UNUSED,
                              long long linenr ATTRIBUTE_UNUSED,
                              const char *timestamp,
+                             virJSONObjectPtr properties ATTRIBUTE_UNUSED,
                              unsigned int flags,
                              const char *rawstr ATTRIBUTE_UNUSED,
                              const char *str,
@@ -899,6 +899,7 @@ static void virLogOutputToSyslog(const char *category ATTRIBUTE_UNUSED,
                                  const char *funcname ATTRIBUTE_UNUSED,
                                  long long linenr ATTRIBUTE_UNUSED,
                                  const char *timestamp ATTRIBUTE_UNUSED,
+                                 virJSONObjectPtr properties ATTRIBUTE_UNUSED,
                                  unsigned int flags,
                                  const char *rawstr ATTRIBUTE_UNUSED,
                                  const char *str,
@@ -928,6 +929,7 @@ static const char *virLogPriorityJSONString(virLogPriority lvl) {
 static void virLogOutputToSyslogJSON(const char *category, int priority,
                                      const char *funcname, long long linenr,
                                      const char *timestamp,
+                                     virJSONObjectPtr properties,
                                      unsigned int flags,
                                      const char *rawstr, const char *str,
                                      void *data ATTRIBUTE_UNUSED)
@@ -980,8 +982,8 @@ static void virLogOutputToSyslogJSON(const char *category, int priority,
 
  error:
     virJSONStringGeneratorFree(g);
-    virLogOutputToSyslog(category, priority, funcname, linenr, timestamp, flags,
-                         rawstr, str, NULL);
+    virLogOutputToSyslog(category, priority, funcname, linenr, timestamp,
+                         properties, flags, rawstr, str, NULL);
 }
 #endif
 
diff --git a/src/util/logging.h b/src/util/logging.h
index 14b7b7c..c1431ec 100644
--- a/src/util/logging.h
+++ b/src/util/logging.h
@@ -90,6 +90,7 @@ typedef enum {
  * @priority: the priority for the message
  * @funcname: the function emitting the message
  * @linenr: line where the message was emitted
+ * @properties: additional JSON properties to add to the log object, or NULL
  * @timestamp: zero terminated string with timestamp of the message
  * @flags: flags associated with the message
  * @rawstr: the unformatted message to log, zero terminated
@@ -101,6 +102,7 @@ typedef enum {
 typedef void (*virLogOutputFunc) (const char *category, int priority,
                                   const char *funcname, long long linenr,
                                   const char *timestamp,
+                                  virJSONObjectPtr properties,
                                   unsigned int flags,
                                   const char *rawstr, const char *str,
                                   void *data);
diff --git a/tests/testutils.c b/tests/testutils.c
index 6978020..abd8424 100644
--- a/tests/testutils.c
+++ b/tests/testutils.c
@@ -484,6 +484,7 @@ virtTestLogOutput(const char *category ATTRIBUTE_UNUSED,
                   const char *funcname ATTRIBUTE_UNUSED,
                   long long lineno ATTRIBUTE_UNUSED,
                   const char *timestamp,
+                  virJSONObjectPtr properties ATTRIBUTE_UNUSED,
                   unsigned int flags,
                   const char *rawstr ATTRIBUTE_UNUSED,
                   const char *str,
-- 
1.7.11.4




More information about the libvir-list mailing list