]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Various logging cleanups in code and doc
authorDaniel Veillard <veillard@redhat.com>
Wed, 1 Jul 2009 11:21:15 +0000 (11:21 +0000)
committerDaniel Veillard <veillard@redhat.com>
Wed, 1 Jul 2009 11:21:15 +0000 (11:21 +0000)
* docs/logging.html[.in] qemud/libvirtd.conf qemud/qemud.c
  src/logging.[ch]: cleanup the logging code and docs to remove
  all references to log level 0, cleanup hardcoded values and add
  a default VIR_LOG_DEFAULT value, patch by Amy Griffis
daniel

ChangeLog
docs/logging.html
docs/logging.html.in
qemud/libvirtd.conf
qemud/qemud.c
src/logging.c
src/logging.h

index 8af5bd4fc24e598f423d8f5fc4f642648aa678c7..d8cc46fe3c497031034aa923d192c9f4a9c4e58a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Wed Jul  1 13:18:37 CEST 2009 Daniel Veillard <veillard@redhat.com>
+
+       * docs/logging.html[.in] qemud/libvirtd.conf qemud/qemud.c
+         src/logging.[ch]: cleanup the logging code and docs to remove
+         all references to log level 0, cleanup hardcoded values and add
+         a default VIR_LOG_DEFAULT value, patch by Amy Griffis
+
 Wed Jul  1 12:38:28 CEST 2009 Daniel Veillard <veillard@redhat.com>
 
        * src/opennebula/one_conf.c src/opennebula/one_driver.c: cleanup
index ea00efab489230e13872e23b8a83a6797c1414ea..b16a7bb42343d60fe27febbb7b1000836b0e27b7 100644 (file)
     variables, stored in the configuration file:
     </p>
         <ul><li>log_level: accepts the following values:
-      <ul><li>0: no logging at all</li><li>4: only errors</li><li>3: warnings and errors</li><li>2: informations, warnings and errors</li><li>1: debug and everything</li></ul></li><li>log_filters: allow to define logging filters</li><li>log_outputs: allow to define logging outputs</li></ul>
+      <ul><li>4: only errors</li><li>3: warnings and errors</li><li>2: informations, warnings and errors</li><li>1: debug and everything</li></ul></li><li>log_filters: allow to define logging filters</li><li>log_outputs: allow to define logging outputs</li></ul>
         <p>In both case the syntax for filters and outputs is similar.</p>
         <p>The format for a filter is:</p>
         <pre>x:name</pre>
       given <code>name</code> as the ident</li><li><code>x:file:file_path</code>output to a file, with the given
       filepath</li></ul>
         <p>In all cases the x prefix is the minimal level, acting as a filter:</p>
-        <ul><li>0: everything</li><li>1: DEBUG</li><li>2: INFO</li><li>3: WARNING</li><li>4: ERROR</li></ul>
+        <ul><li>1: DEBUG</li><li>2: INFO</li><li>3: WARNING</li><li>4: ERROR</li></ul>
         <p>Multiple output can be defined , they just need to be separated by
-       spaces, e.g.: <code>"3:syslog:libvirtd 0:file:/tmp/libvirt.log"</code>
+       spaces, e.g.: <code>"3:syslog:libvirtd 1:file:/tmp/libvirt.log"</code>
        will log all warnings and errors to syslog under the libvirtd ident
        but also log everything debugging and informations included in the
        file <code>/tmp/libvirt.log</code></p>
         <p>For example setting up the following:</p>
         <pre>export LIBVIRT_DEBUG=1
-export LIBVIRT_LOG_OUTPUTS="0:file:virsh.log"</pre>
+export LIBVIRT_LOG_OUTPUTS="1:file:virsh.log"</pre>
         <p>and then running virsh will accumulate the logs in the
     <code>virsh.log</code> file in a way similar to:</p>
         <pre>14:29:04.771: debug : virInitialize:278 : register drivers
index 11ea68ca21b6ad1e0d8dfc05ff7511c6f308f2ed..fcd100ff528612e8b333bd1aa85f87b88b259da3 100644 (file)
@@ -49,7 +49,6 @@
     <ul>
       <li>log_level: accepts the following values:
       <ul>
-        <li>0: no logging at all</li>
         <li>4: only errors</li>
         <li>3: warnings and errors</li>
         <li>2: informations, warnings and errors</li>
     </ul>
     <p>In all cases the x prefix is the minimal level, acting as a filter:</p>
     <ul>
-      <li>0: everything</li>
       <li>1: DEBUG</li>
       <li>2: INFO</li>
       <li>3: WARNING</li>
       <li>4: ERROR</li>
     </ul>
     <p>Multiple output can be defined , they just need to be separated by
-       spaces, e.g.: <code>"3:syslog:libvirtd 0:file:/tmp/libvirt.log"</code>
+       spaces, e.g.: <code>"3:syslog:libvirtd 1:file:/tmp/libvirt.log"</code>
        will log all warnings and errors to syslog under the libvirtd ident
        but also log everything debugging and informations included in the
        file <code>/tmp/libvirt.log</code></p>
     <p>For example setting up the following:</p>
     <pre>export LIBVIRT_DEBUG=1
-export LIBVIRT_LOG_OUTPUTS="0:file:virsh.log"</pre>
+export LIBVIRT_LOG_OUTPUTS="1:file:virsh.log"</pre>
     <p>and then running virsh will accumulate the logs in the
     <code>virsh.log</code> file in a way similar to:</p>
     <pre>14:29:04.771: debug : virInitialize:278 : register drivers
index 1fd5918d88f83c13439813e0adacdb2eeab375a3..49de46634964fcfbdcc4aa3ebbe08484a4c08792 100644 (file)
 # Logging controls
 #
 
-# Logging level: 0 none, 4 errors, 3 warnings, 2 informations, 1 debug
+# Logging level: 4 errors, 3 warnings, 2 informations, 1 debug
 # basically 1 will log everything possible
 #log_level = 3
 
 #    x:file:file_path
 #      output to a file, with the given filepath
 # In all case the x prefix is the minimal level, acting as a filter
-#    0: everything
 #    1: DEBUG
 #    2: INFO
 #    3: WARNING
 #    4: ERROR
 #
-# Multiple output can be defined , they just need to be separated by spaces.
+# Multiple output can be defined, they just need to be separated by spaces.
 # e.g.:
 # log_outputs="3:syslog:libvirtd"
 # to log all warnings and errors to syslog under the libvirtd ident
index b5e36651b4b5b776873ede5698fa3fa9aca9e93e..da20aa94da50a2c944fcdcdf5a2567b88868cb44 100644 (file)
@@ -128,7 +128,7 @@ static int sigwrite = -1;       /* Signal handler pipe */
 static int ipsock = 0;          /* -l  Listen for TCP/IP */
 
 /* Defaults for logging */
-static int log_level = 3;
+static int log_level = VIR_LOG_DEFAULT;
 static char *log_filters = NULL;
 static char *log_outputs = NULL;
 
@@ -2499,15 +2499,16 @@ qemudSetLogging(virConfPtr conf, const char *filename) {
             log_outputs = strdup(debugEnv);
     }
     if (!log_outputs) {
+        char *tmp = NULL;
         if (godaemon) {
-            char *tmp = NULL;
             if (virAsprintf (&tmp, "%d:syslog:libvirtd", log_level) < 0)
                 goto free_and_fail;
-            virLogParseOutputs (tmp);
-            VIR_FREE (tmp);
         } else {
-            virLogParseOutputs("0:stderr:libvirtd");
+            if (virAsprintf(&tmp, "%d:stderr", log_level) < 0)
+                goto free_and_fail;
         }
+        virLogParseOutputs(tmp);
+        VIR_FREE(tmp);
     } else {
         virLogParseOutputs(log_outputs);
     }
index fd1d5d4d41310e16debd6740c3020128769fb179..d13ae0f20c8f9730e7b95cd53c303bccf8ac1619 100644 (file)
@@ -119,7 +119,7 @@ static int virLogNbOutputs = 0;
 /*
  * Default priorities
  */
-static virLogPriority virLogDefaultPriority = VIR_LOG_WARN;
+static virLogPriority virLogDefaultPriority = VIR_LOG_DEFAULT;
 
 static int virLogResetFilters(void);
 static int virLogResetOutputs(void);
@@ -174,7 +174,7 @@ int virLogStartup(void) {
     virLogLen = 0;
     virLogStart = 0;
     virLogEnd = 0;
-    virLogDefaultPriority = VIR_LOG_WARN;
+    virLogDefaultPriority = VIR_LOG_DEFAULT;
     virLogUnlock();
     return(0);
 }
@@ -196,7 +196,7 @@ int virLogReset(void) {
     virLogLen = 0;
     virLogStart = 0;
     virLogEnd = 0;
-    virLogDefaultPriority = VIR_LOG_WARN;
+    virLogDefaultPriority = VIR_LOG_DEFAULT;
     virLogUnlock();
     return(0);
 }
@@ -689,7 +689,7 @@ int virLogParseOutputs(const char *outputs) {
     virSkipSpaces(&cur);
     while (*cur != 0) {
         prio= virParseNumber(&cur);
-        if ((prio < 0) || (prio > 4))
+        if ((prio < VIR_LOG_DEBUG) || (prio > VIR_LOG_ERROR))
             return(-1);
         if (*cur != ':')
             return(-1);
@@ -770,7 +770,7 @@ int virLogParseFilters(const char *filters) {
     virSkipSpaces(&cur);
     while (*cur != 0) {
         prio= virParseNumber(&cur);
-        if ((prio < 0) || (prio > 4))
+        if ((prio < VIR_LOG_DEBUG) || (prio > VIR_LOG_ERROR))
             return(-1);
         if (*cur != ':')
             return(-1);
index d99bb31b707d322fea7eb600fe1371332a8c9ff2..0b9ae793b285e24df6974031aaf8ca3186ae36c3 100644 (file)
@@ -77,6 +77,8 @@ typedef enum {
     VIR_LOG_ERROR,
 } virLogPriority;
 
+#define VIR_LOG_DEFAULT VIR_LOG_WARN
+
 /**
  * virLogOutputFunc:
  * @category: the category for the message