From: Ben Pfaff Date: Sat, 3 Jan 2009 01:26:26 +0000 (-0800) Subject: vswitchd: Improve log options passed down to secchan. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=954a27281b175dd0429dd1bfa155fd2e35e8108d;p=openvswitch vswitchd: Improve log options passed down to secchan. Previously, secchan as started by vswitchd would always log to the console. Now, it logs to the console only if any logging to the console is enabled for vswitchd. Previously, secchan as started by vswitchd would never log to a file. Now, it logs to a file if vswitchd is configured to do so. Also, use the bridge name in the vlog log pattern, instead of the datapath number, so that users can more easily relate log messages to bridges. Requested by Keith. --- diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c index 17c6dc88..b92a5fce 100644 --- a/vswitchd/bridge.c +++ b/vswitchd/bridge.c @@ -529,6 +529,19 @@ run_secchan(struct bridge *br) } } +static bool +console_logging_enabled(void) +{ + enum vlog_module module; + + for (module = 0; module < VLM_N_MODULES; module++) { + if (vlog_get_level(module, VLF_CONSOLE) != VLL_EMER) { + return true; + } + } + return false; +} + static void start_secchan(struct bridge *br) { @@ -575,6 +588,18 @@ start_secchan(struct bridge *br) /* Assemble command-line arguments. */ svec_init(&argv); svec_add(&argv, "secchan"); + svec_add_nocopy(&argv, xasprintf("-vPATTERN:console:%s|secchan-%s|%s", + "%d{%b %d %H:%M:%S}", br->name, + "%c|%p|%m")); + svec_add_nocopy(&argv, xasprintf("-vPATTERN:syslog:secchan-%s|%s", + br->name, "%05N|%c|%p|%m")); + if (!console_logging_enabled()) { + svec_add(&argv, "-vANY:console:EMER"); + } + if (vlog_get_log_file()) { + svec_add_nocopy(&argv, xasprintf("--log-file=%s.secchan-%s", + vlog_get_log_file(), br->name)); + } if (!br->controller) { svec_add(&argv, "--out-of-band"); svec_add(&argv, "--max-backoff=1"); @@ -583,14 +608,9 @@ start_secchan(struct bridge *br) svec_add(&argv, "--no-stp"); if (!stat(ofp_rundir, &s)) { svec_add_nocopy(&argv, - xasprintf("--monitor=punix:%s/secchan%d.monitor", - ofp_rundir, br->dp_idx)); - } - svec_add_nocopy(&argv, - xasprintf("-vPATTERN:console:%s|secchan(nl:%d)|%s", - "%d{%b %d %H:%M:%S}", - br->dp_idx, - "%c|%p|%m")); + xasprintf("--monitor=punix:%s/secchan.monitor-%s", + ofp_rundir, br->name)); + } svec_append(&argv, &br->secchan_opts); svec_add_nocopy(&argv, xasprintf("nl:%d", br->dp_idx)); if (br->controller) {