Quoting William Dauchy (wdau...@gmail.com):
> Hi Serge,
> 
> Thank you for your reply.
> 
> On Thu, Sep 4, 2014 at 8:19 PM, Serge Hallyn <serge.hal...@ubuntu.com> wrote:
> > Or should lxc_log_options_no_override() be updated to also make
> > future lxc_log_init() calls not do the if (!quiet) part?
> 
> Do you think this could be acceptable? (not tested yet)

Almost - except it won't quite do what you want in this case.
Maybe something like the following (also untested) ?  Otherwise
lxc-attach -F won't be honored, because the appender will be
reset to log_appender_logfile, and bc lxc_quiet_specified is true
stderr won't be re-appended.

diff --git a/src/lxc/log.c b/src/lxc/log.c
index b6b3931..3080cf6 100644
--- a/src/lxc/log.c
+++ b/src/lxc/log.c
@@ -49,6 +49,7 @@ 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";
@@ -58,6 +59,7 @@ static char *log_fname = NULL;
  */
 static int lxc_logfile_specified = 0;
 static int lxc_loglevel_specified = 0;
+static int lxc_quiet_specified = 0;
 #endif
 
 lxc_log_define(lxc_log, lxc);
@@ -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;
 }
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to