]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
log: fix quiet mode
authorWilliam Dauchy <william@gandi.net>
Thu, 18 Sep 2014 15:18:55 +0000 (17:18 +0200)
committerStéphane Graber <stgraber@ubuntu.com>
Fri, 19 Sep 2014 21:59:10 +0000 (17:59 -0400)
quiet mode was overriden by the double call of lxc_log_init
see lxc_container_new

use lxc_log_options_no_override in order to fix this

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Signed-off-by: William Dauchy <william@gandi.net>
src/lxc/log.c

index b6b393157a6b2f571f95621819ba9b5ad2bf222a..e3c64ee0eab94424ca1aa011d40c5024a0608f05 100644 (file)
@@ -49,10 +49,12 @@ static __thread char *log_fname = NULL;
  */
 static __thread int lxc_logfile_specified = 0;
 static __thread int lxc_loglevel_specified = 0;
+static __thread int lxc_quiet_specified = 0;
 #else
 int lxc_log_fd = -1;
 static char log_prefix[LXC_LOG_PREFIX_SIZE] = "lxc";
 static char *log_fname = NULL;
+static int lxc_quiet_specified = 0;
 /* command line values for logfile or logpriority should always override
  * values from the configuration file or defaults
  */
@@ -316,10 +318,12 @@ extern int lxc_log_init(const char *name, const char *file,
                lxc_priority = lxc_log_priority_to_int(priority);
 
        lxc_log_category_lxc.priority = lxc_priority;
-       lxc_log_category_lxc.appender = &log_appender_logfile;
 
-       if (!quiet)
-               lxc_log_category_lxc.appender->next = &log_appender_stderr;
+       if (!lxc_quiet_specified) {
+               lxc_log_category_lxc.appender = &log_appender_logfile;
+               if (!quiet)
+                       lxc_log_category_lxc.appender->next = &log_appender_stderr;
+       }
 
        if (prefix)
                lxc_log_set_prefix(prefix);
@@ -438,4 +442,6 @@ extern void lxc_log_options_no_override()
 
        if (lxc_log_get_level() != LXC_LOG_PRIORITY_NOTSET)
                lxc_loglevel_specified = 1;
+
+       lxc_quiet_specified = 1;
 }