Make facility and level optional in -v, --verbose options.
authorBen Pfaff <blp@nicira.com>
Mon, 14 Jul 2008 21:10:18 +0000 (14:10 -0700)
committerBen Pfaff <blp@nicira.com>
Fri, 18 Jul 2008 21:16:40 +0000 (14:16 -0700)
This makes it easier to set a given module to maximum verbosity,
as is often useful for debugging.

12 files changed:
controller/controller.8.in
controller/controller.c
lib/vlog.c
secchan/secchan.8.in
secchan/secchan.c
switch/switch.8.in
switch/switch.c
tests/test-dhcp-client.c
utilities/dpctl.8
utilities/dpctl.c
utilities/vlogconf.8
utilities/vlogconf.c

index d3c9195..25f9c32 100644 (file)
@@ -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
index e0b8b88..c43926c 100644 (file)
@@ -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",
index 1d70a5d..6b3d871 100644 (file)
@@ -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);
index 8cf8ee8..dc1c788 100644 (file)
@@ -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
index 8638dc7..886b2a2 100644 (file)
@@ -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",
index 6617101..a4fcb0e 100644 (file)
@@ -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
index 01fb4b8..6cc6ae4 100644 (file)
@@ -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",
index 4ed6fc0..528d1b1 100644 (file)
@@ -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",
index 2eb26db..043ff14 100644 (file)
@@ -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
index 7cdb324..f5b2ade 100644 (file)
@@ -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");
index 8555fd5..74e8161 100644 (file)
@@ -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
index 9fbcc84..f42740d 100644 (file)
@@ -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);