[CRIU] [PATCH] criu: change the way -v works
Kir Kolyshkin
kir at openvz.org
Thu Feb 9 19:56:45 PST 2017
For most of the CLI tools I see, adding -v option increases their verbosity.
Currently, this is not the case for criu. Default verbosity is set it 2,
and using -v actually decreases the verbosity level to 1, so to increase
verbosity you need to use -vvv (or -v3). To me, this behavior is
quite counterintuitive.
This patch changes the way -v works (but retains -vNUM as it was). Now,
using -v increases verbosity by +1 from the default value (and e.g. -vvv
increases it by +3).
Surely, this changes user experience: for example someone who
was using -v (rather than -v1 or -v0) to silent warnings, will
now have verbosity increased. IMHO this is for the better.
Signed-off-by: Kir Kolyshkin <kir at openvz.org>
---
Documentation/criu.txt | 28 +++++++++++++++++-----------
criu/crtools.c | 15 +++++++--------
criu/log.c | 5 +----
3 files changed, 25 insertions(+), 23 deletions(-)
diff --git a/Documentation/criu.txt b/Documentation/criu.txt
index 04359ae..1d64f7f 100644
--- a/Documentation/criu.txt
+++ b/Documentation/criu.txt
@@ -28,19 +28,25 @@ Common options
~~~~~~~~~~~~~~
Common options are applicable to any 'command'.
-*-v*['num'|*v*...]::
- Set logging level to 'num'. The higher the level, the more output
- is produced. Either numeric values or multiple *v* can be used.
+*-v*[*v*...]::
+ Increase verbosity up from the default level. Multiple *v* can be used,
+ each increasing verbosity by one level.
+
+*-v*'num'::
+ Set verbosity level to 'num'. The higher the level, the more output
+ is produced.
+
The following levels are available:
- * *-v1*, *-v*
- only messages and errors;
- * *-v2*, *-vv*
- also warnings (default level);
- * *-v3*, *-vvv*
- also information messages and timestamps;
- * *-v4*, *-vvvv*
- lots of debug.
+ * *-v0*
+ no output;
+ * *-v1*
+ only errors;
+ * *-v2*
+ above plus warnings (this is the default level);
+ * *-v3*
+ above plus information messages and timestamps;
+ * *-v4*
+ above plus lots of debug.
*--pidfile* 'file'::
Write root task, service or page-server pid into a 'file'.
diff --git a/criu/crtools.c b/criu/crtools.c
index cce8073..eb830b3 100644
--- a/criu/crtools.c
+++ b/criu/crtools.c
@@ -217,7 +217,7 @@ int main(int argc, char *argv[], char *envp[])
bool has_exec_cmd = false;
bool has_sub_command;
int opt, idx;
- int log_level = LOG_UNSET;
+ int log_level = DEFAULT_LOGLEVEL;
char *imgs_dir = ".";
static const char short_opts[] = "dSsRf:F:t:p:hcD:o:v::x::Vr:jJ:lW:L:M:";
static struct option long_opts[] = {
@@ -383,8 +383,6 @@ int main(int argc, char *argv[], char *envp[])
goto bad_arg;
break;
case 'v':
- if (log_level == LOG_UNSET)
- log_level = 0;
if (optarg) {
if (optarg[0] == 'v')
/* handle -vvvvv */
@@ -951,11 +949,12 @@ usage:
"* Logging:\n"
" -o|--log-file FILE log file name\n"
" --log-pid enable per-process logging to separate FILE.pid files\n"
-" -v[NUM] set logging level (higher level means more output):\n"
-" -v1|-v - only errors and messages\n"
-" -v2|-vv - also warnings (default level)\n"
-" -v3|-vvv - also information messages and timestamps\n"
-" -v4|-vvvv - lots of debug\n"
+" -v[v...] increase verbosity (can use multiple v)\n"
+" -vNUM set verbosity to NUM (higher level means more output):\n"
+" -v1 - only errors and messages\n"
+" -v2 - also warnings (default level)\n"
+" -v3 - also information messages and timestamps\n"
+" -v4 - lots of debug\n"
" --display-stats print out dump/restore stats\n"
"\n"
"* Memory dumping options:\n"
diff --git a/criu/log.c b/criu/log.c
index 7997c2e..a2beabd 100644
--- a/criu/log.c
+++ b/criu/log.c
@@ -201,10 +201,7 @@ void log_fini(void)
void log_set_loglevel(unsigned int level)
{
- if (level == LOG_UNSET)
- current_loglevel = DEFAULT_LOGLEVEL;
- else
- current_loglevel = level;
+ current_loglevel = level;
}
unsigned int log_get_loglevel(void)
--
2.9.3
More information about the CRIU
mailing list