From 1b6df17a65624f5491872de5a8683b76c4420895 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Mon, 14 Jul 2008 14:10:18 -0700 Subject: [PATCH] Make facility and level optional in -v, --verbose options. This makes it easier to set a given module to maximum verbosity, as is often useful for debugging. --- controller/controller.8.in | 11 ++++++----- controller/controller.c | 2 +- lib/vlog.c | 10 +++------- secchan/secchan.8.in | 11 ++++++----- secchan/secchan.c | 2 +- switch/switch.8.in | 11 ++++++----- switch/switch.c | 2 +- tests/test-dhcp-client.c | 2 +- utilities/dpctl.8 | 11 ++++++----- utilities/dpctl.c | 2 +- utilities/vlogconf.8 | 24 +++++++++++++----------- utilities/vlogconf.c | 6 +++--- 12 files changed, 48 insertions(+), 46 deletions(-) diff --git a/controller/controller.8.in b/controller/controller.8.in index d3c91957..25f9c322 100644 --- a/controller/controller.8.in +++ b/controller/controller.8.in @@ -118,17 +118,18 @@ run as a background process. Prints a brief help message to the console. .TP -\fB-v\fR \fImodule\fB:\fIfacility\fB:\fIlevel\fR, \fB--verbose=\fImodule\fB:\fIfacility\fB:\fIlevel\fR +\fB-v\fImodule\fR[\fB:\fIfacility\fR[\fB:\fIlevel\fR]], \fB--verbose=\fImodule\fR[\fB:\fIfacility\fR[\fB:\fIlevel\fR]] Sets the logging level for \fImodule\fR in \fIfacility\fR to \fIlevel\fR. The \fImodule\fR may be any valid module name (as displayed by the \fB--list\fR action on \fBvlogconf\fR(8)), or the special name \fBANY\fR to set the logging levels for all modules. The \fIfacility\fR may be \fBsyslog\fR or \fBconsole\fR to set the levels for logging to the system log or to the console, respectively, or -\fBANY\fR to set the logging levels for both facilities. The -\fIlevel\fR must be one of \fBemer\fR, \fBerr\fR, \fBwarn\fR, or -\fBdbg\fR, designating the minimum severity of a message for it to be -logged. +\fBANY\fR to set the logging levels for both facilities. If it is +omitted, \fIfacility\fR defaults to \fBANY\fR. The \fIlevel\fR must +be one of \fBemer\fR, \fBerr\fR, \fBwarn\fR, or \fBdbg\fR, designating +the minimum severity of a message for it to be logged. If it is +omitted, \fIlevel\fR defaults to \fBdbg\fR. .TP \fB-v\fR, \fB--verbose\fR diff --git a/controller/controller.c b/controller/controller.c index e0b8b88d..c43926c4 100644 --- a/controller/controller.c +++ b/controller/controller.c @@ -311,7 +311,7 @@ usage(void) " -H, --hub act as hub instead of learning switch\n" " -n, --noflow pass traffic, but don't add flows\n" " --max-idle=SECS max idle time for new flows\n" - " -v, --verbose=MODULE:FACILITY:LEVEL configure logging levels\n" + " -v, --verbose=MODULE[:FACILITY[:LEVEL]] set logging levels\n" " -v, --verbose set maximum verbosity level\n" " -h, --help display this help message\n" " -V, --version display version information\n", diff --git a/lib/vlog.c b/lib/vlog.c index 1d70a5d9..6b3d871f 100644 --- a/lib/vlog.c +++ b/lib/vlog.c @@ -174,7 +174,7 @@ vlog_set_levels(enum vlog_module module, enum vlog_facility facility, /* Set debugging levels: * - * mod:facility:level mod2:facility:level ... + * mod[:facility[:level]] mod2[:facility[:level]] ... * * Return null if successful, otherwise an error message that the caller must * free(). @@ -194,10 +194,6 @@ vlog_set_levels_from_string(const char *s_) facility = strtok_r(NULL, ":", &save_ptr); level = strtok_r(NULL, ":", &save_ptr); - if (level == NULL || facility == NULL) { - free(s); - return xstrdup("syntax error in level string"); - } if (!strcmp(module, "ANY")) { e_module = VLM_ANY_MODULE; @@ -210,7 +206,7 @@ vlog_set_levels_from_string(const char *s_) } } - if (!strcmp(facility, "ANY")) { + if (!facility || !strcmp(facility, "ANY")) { e_facility = VLF_ANY_FACILITY; } else { e_facility = vlog_get_facility_val(facility); @@ -221,7 +217,7 @@ vlog_set_levels_from_string(const char *s_) } } - e_level = vlog_get_level_val(level); + e_level = level ? vlog_get_level_val(level) : VLL_DBG; if (e_level >= VLL_N_LEVELS) { char *msg = xasprintf("unknown level \"%s\"", level); free(s); diff --git a/secchan/secchan.8.in b/secchan/secchan.8.in index 8cf8ee8b..dc1c7883 100644 --- a/secchan/secchan.8.in +++ b/secchan/secchan.8.in @@ -210,17 +210,18 @@ run as a background process. Prints a brief help message to the console. .TP -\fB-v\fR \fImodule\fB:\fIfacility\fB:\fIlevel\fR, \fB--verbose=\fImodule\fB:\fIfacility\fB:\fIlevel\fR +\fB-v\fR \fImodule\fR[\fB:\fIfacility\fR[\fB:\fIlevel\fR]], \fB--verbose=\fImodule\fR[\fB:\fIfacility\fR[\fB:\fIlevel\fR]] Sets the logging level for \fImodule\fR in \fIfacility\fR to \fIlevel\fR. The \fImodule\fR may be any valid module name (as displayed by the \fB--list\fR action on \fBvlogconf\fR(8)), or the special name \fBANY\fR to set the logging levels for all modules. The \fIfacility\fR may be \fBsyslog\fR or \fBconsole\fR to set the levels for logging to the system log or to the console, respectively, or -\fBANY\fR to set the logging levels for both facilities. The -\fIlevel\fR must be one of \fBemer\fR, \fBerr\fR, \fBwarn\fR, or -\fBdbg\fR, designating the minimum severity of a message for it to be -logged. +\fBANY\fR to set the logging levels for both facilities. If it is +omitted, \fIfacility\fR defaults to \fBANY\fR. The \fIlevel\fR must +be one of \fBemer\fR, \fBerr\fR, \fBwarn\fR, or \fBdbg\fR, designating +the minimum severity of a message for it to be logged. If it is +omitted, \fIlevel\fR defaults to \fBdbg\fR. .TP \fB-v\fR, \fB--verbose\fR diff --git a/secchan/secchan.c b/secchan/secchan.c index 8638dc76..886b2a2e 100644 --- a/secchan/secchan.c +++ b/secchan/secchan.c @@ -681,7 +681,7 @@ usage(void) "\nOther options:\n" " -D, --detach run in background as daemon\n" " -P, --pidfile[=FILE] create pidfile (default: %s/secchan.pid)\n" - " -v, --verbose=MODULE:FACILITY:LEVEL configure logging levels\n" + " -v, --verbose=MODULE[:FACILITY[:LEVEL]] set logging levels\n" " -v, --verbose set maximum verbosity level\n" " -h, --help display this help message\n" " -V, --version display version information\n", diff --git a/switch/switch.8.in b/switch/switch.8.in index 6617101b..a4fcb0e7 100644 --- a/switch/switch.8.in +++ b/switch/switch.8.in @@ -97,17 +97,18 @@ run as a background process. Prints a brief help message to the console. .TP -\fB-v\fR \fImodule\fB:\fIfacility\fB:\fIlevel\fR, \fB--verbose=\fImodule\fB:\fIfacility\fB:\fIlevel\fR +\fB-v\fImodule\fR[\fB:\fIfacility\fR[\fB:\fIlevel\fR]], \fB--verbose=\fImodule\fR[\fB:\fIfacility\fR[\fB:\fIlevel\fR]] Sets the logging level for \fImodule\fR in \fIfacility\fR to \fIlevel\fR. The \fImodule\fR may be any valid module name (as displayed by the \fB--list\fR action on \fBvlogconf\fR(8)), or the special name \fBANY\fR to set the logging levels for all modules. The \fIfacility\fR may be \fBsyslog\fR or \fBconsole\fR to set the levels for logging to the system log or to the console, respectively, or -\fBANY\fR to set the logging levels for both facilities. The -\fIlevel\fR must be one of \fBemer\fR, \fBerr\fR, \fBwarn\fR, or -\fBdbg\fR, designating the minimum severity of a message for it to be -logged. +\fBANY\fR to set the logging levels for both facilities. If it is +omitted, \fIfacility\fR defaults to \fBANY\fR. The \fIlevel\fR must +be one of \fBemer\fR, \fBerr\fR, \fBwarn\fR, or \fBdbg\fR, designating +the minimum severity of a message for it to be logged. If it is +omitted, \fIlevel\fR defaults to \fBdbg\fR. .TP \fB-v\fR, \fB--verbose\fR diff --git a/switch/switch.c b/switch/switch.c index 01fb4b82..6cc6ae4e 100644 --- a/switch/switch.c +++ b/switch/switch.c @@ -262,7 +262,7 @@ usage(void) "\nOther options:\n" " -D, --detach run in background as daemon\n" " -P, --pidfile[=FILE] create pidfile (default: %s/switch.pid)\n" - " -v, --verbose=MODULE:FACILITY:LEVEL configure logging levels\n" + " -v, --verbose=MODULE[:FACILITY[:LEVEL]] set logging levels\n" " -v, --verbose set maximum verbosity level\n" " -h, --help display this help message\n" " -V, --version display version information\n", diff --git a/tests/test-dhcp-client.c b/tests/test-dhcp-client.c index 4ed6fc0a..528d1b19 100644 --- a/tests/test-dhcp-client.c +++ b/tests/test-dhcp-client.c @@ -175,7 +175,7 @@ usage(void) " --vendor-class=STRING use STRING as vendor class (default:\n" " none); use OpenFlow to imitate secchan\n" "\nOther options:\n" - " -v, --verbose=MODULE:FACILITY:LEVEL configure logging levels\n" + " -v, --verbose=MODULE[:FACILITY[:LEVEL]] set logging levels\n" " -v, --verbose set maximum verbosity level\n" " -h, --help display this help message\n" " -V, --version display version information\n", diff --git a/utilities/dpctl.8 b/utilities/dpctl.8 index 2eb26dba..043ff143 100644 --- a/utilities/dpctl.8 +++ b/utilities/dpctl.8 @@ -321,17 +321,18 @@ a switch is trustworthy. Prints a brief help message to the console. .TP -\fB-v\fR \fImodule\fB:\fIfacility\fB:\fIlevel\fR, \fB--verbose=\fImodule\fB:\fIfacility\fB:\fIlevel\fR +\fB-v\fImodule\fR[\fB:\fIfacility\fR[\fB:\fIlevel\fR]], \fB--verbose=\fImodule\fR[\fB:\fIfacility\fR[\fB:\fIlevel\fR]] Sets the logging level for \fImodule\fR in \fIfacility\fR to \fIlevel\fR. The \fImodule\fR may be any valid module name (as displayed by the \fB--list\fR action on \fBvlogconf\fR(8)), or the special name \fBANY\fR to set the logging levels for all modules. The \fIfacility\fR may be \fBsyslog\fR or \fBconsole\fR to set the levels for logging to the system log or to the console, respectively, or -\fBANY\fR to set the logging levels for both facilities. The -\fIlevel\fR must be one of \fBemer\fR, \fBerr\fR, \fBwarn\fR, or -\fBdbg\fR, designating the minimum severity of a message for it to be -logged. +\fBANY\fR to set the logging levels for both facilities. If it is +omitted, \fIfacility\fR defaults to \fBANY\fR. The \fIlevel\fR must +be one of \fBemer\fR, \fBerr\fR, \fBwarn\fR, or \fBdbg\fR, designating +the minimum severity of a message for it to be logged. If it is +omitted, \fIlevel\fR defaults to \fBdbg\fR. .TP \fB-v\fR, \fB--verbose\fR diff --git a/utilities/dpctl.c b/utilities/dpctl.c index 7cdb324c..f5b2adec 100644 --- a/utilities/dpctl.c +++ b/utilities/dpctl.c @@ -206,7 +206,7 @@ usage(void) vconn_usage(true, false); printf("\nOptions:\n" " -t, --timeout=SECS give up after SECS seconds\n" - " -v, --verbose=MODULE:FACILITY:LEVEL configure logging levels\n" + " -v, --verbose=MODULE[:FACILITY[:LEVEL]] set logging levels\n" " -v, --verbose set maximum verbosity level\n" " -h, --help display this help message\n" " -V, --version display version information\n"); diff --git a/utilities/vlogconf.8 b/utilities/vlogconf.8 index 8555fd56..74e81616 100644 --- a/utilities/vlogconf.8 +++ b/utilities/vlogconf.8 @@ -13,8 +13,8 @@ The available \fItarget\fR options are: The available \fIaction\fR options are: .br [\fB-l\fR | \fB--list\fR] [\fB-s\fR -\fImodule\fB:\fIfacility\fB:\fIlevel\fR | -\fB--set=\fImodule\fB:\fIfacility\fB:\fIlevel\fR] +\fImodule\fR[\fB:\fIfacility\fR[\fB:\fIlevel\fR]] | +\fB--set=\fImodule\fR[\fB:\fIfacility\fR[\fB:\fIlevel\fR]]] .SH DESCRIPTION The \fBvlogconf\fR program configures the logging system used by @@ -43,17 +43,19 @@ Print the list of known modules and their current logging levels to stdout. .TP -\fB-s\fR \fImodule\fB:\fIfacility\fB:\fIlevel\fR, \fB--set=\fImodule\fB:\fIfacility\fB:\fIlevel\fR +\fB-s\fR \fImodule\fR[\fB:\fIfacility\fR[\fB:\fIlevel\fR]], \fB--set=\fImodule\fR[\fB:\fIfacility\fR[\fB:\fIlevel\fR]] Sets the logging level for \fImodule\fR in \fIfacility\fR to -\fIlevel\fR. The \fImodule\fR may be any valid module name (as displayed -by the \fB--list\fR option) or the special name \fBANY\fR to set the -logging levels for all modules. The \fIfacility\fR may be \fBsyslog\fR or -\fBconsole\fR to set the levels for logging to the system log or to -the console, respectively, or \fBANY\fR to set the logging levels for -both facilities. The \fIlevel\fR must be one of \fBemer\fR, \fBerr\fR, -\fBwarn\fR, or \fBdbg\fR, designating the minimum severity of a -message for it to be logged. +\fIlevel\fR. The \fImodule\fR may be any valid module name (as +displayed by the \fB--list\fR option) or the special name \fBANY\fR to +set the logging levels for all modules. The \fIfacility\fR may be +\fBsyslog\fR or \fBconsole\fR to set the levels for logging to the +system log or to the console, respectively, or \fBANY\fR to set the +logging levels for both facilities. If it is omitted, +\fIfacility\fR defaults to \fBANY\fR. The \fIlevel\fR must be one of +\fBemer\fR, \fBerr\fR, \fBwarn\fR, or \fBdbg\fR, designating the +minimum severity of a message for it to be logged. If it is omitted, +\fIlevel\fR defaults to \fBdbg\fR. .SH OPTIONS .TP diff --git a/utilities/vlogconf.c b/utilities/vlogconf.c index 9fbcc849..f42740d8 100644 --- a/utilities/vlogconf.c +++ b/utilities/vlogconf.c @@ -55,11 +55,11 @@ usage(char *prog_name, int exit_code) " absolute path to a Unix domain socket\n" "Actions:\n" " -l, --list List current settings\n" - " -s, --set=MODULE:FACILITY:LEVEL\n" + " -s, --set=MODULE[:FACILITY[:LEVEL]]\n" " Set MODULE and FACILITY log level to LEVEL\n" " MODULE may be any valid module name or 'ANY'\n" - " FACILITY may be 'syslog' or 'console' or 'ANY'\n" - " LEVEL may be 'emer', 'err', 'warn', or 'dbg'\n" + " FACILITY may be 'syslog' or 'console' or 'ANY' (default)\n" + " LEVEL may be 'emer', 'err', 'warn', or 'dbg (default)'\n" " -h, --help Print this helpful information\n", prog_name); exit(exit_code); -- 2.30.2