Commit c4247302 authored by Kir Kolyshkin's avatar Kir Kolyshkin Committed by Andrei Vagin

criu: change the way -v works

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: 's avatarKir Kolyshkin <kir@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent c58d3394
...@@ -28,19 +28,25 @@ Common options ...@@ -28,19 +28,25 @@ Common options
~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~
Common options are applicable to any 'command'. Common options are applicable to any 'command'.
*-v*['num'|*v*...]:: *-v*[*v*...]::
Set logging level to 'num'. The higher the level, the more output Increase verbosity up from the default level. Multiple *v* can be used,
is produced. Either numeric values or 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: The following levels are available:
* *-v1*, *-v* * *-v0*
only messages and errors; no output;
* *-v2*, *-vv* * *-v1*
also warnings (default level); only errors;
* *-v3*, *-vvv* * *-v2*
also information messages and timestamps; above plus warnings (this is the default level);
* *-v4*, *-vvvv* * *-v3*
lots of debug. above plus information messages and timestamps;
* *-v4*
above plus lots of debug.
*--pidfile* 'file':: *--pidfile* 'file'::
Write root task, service or page-server pid into a 'file'. Write root task, service or page-server pid into a 'file'.
......
...@@ -217,7 +217,7 @@ int main(int argc, char *argv[], char *envp[]) ...@@ -217,7 +217,7 @@ int main(int argc, char *argv[], char *envp[])
bool has_exec_cmd = false; bool has_exec_cmd = false;
bool has_sub_command; bool has_sub_command;
int opt, idx; int opt, idx;
int log_level = LOG_UNSET; int log_level = DEFAULT_LOGLEVEL;
char *imgs_dir = "."; char *imgs_dir = ".";
static const char short_opts[] = "dSsRf:F:t:p:hcD:o:v::x::Vr:jJ:lW:L:M:"; static const char short_opts[] = "dSsRf:F:t:p:hcD:o:v::x::Vr:jJ:lW:L:M:";
static struct option long_opts[] = { static struct option long_opts[] = {
...@@ -381,8 +381,6 @@ int main(int argc, char *argv[], char *envp[]) ...@@ -381,8 +381,6 @@ int main(int argc, char *argv[], char *envp[])
goto bad_arg; goto bad_arg;
break; break;
case 'v': case 'v':
if (log_level == LOG_UNSET)
log_level = 0;
if (optarg) { if (optarg) {
if (optarg[0] == 'v') if (optarg[0] == 'v')
/* handle -vvvvv */ /* handle -vvvvv */
...@@ -928,11 +926,12 @@ usage: ...@@ -928,11 +926,12 @@ usage:
"* Logging:\n" "* Logging:\n"
" -o|--log-file FILE log file name\n" " -o|--log-file FILE log file name\n"
" --log-pid enable per-process logging to separate FILE.pid files\n" " --log-pid enable per-process logging to separate FILE.pid files\n"
" -v[NUM] set logging level (higher level means more output):\n" " -v[v...] increase verbosity (can use multiple v)\n"
" -v1|-v - only errors and messages\n" " -vNUM set verbosity to NUM (higher level means more output):\n"
" -v2|-vv - also warnings (default level)\n" " -v1 - only errors and messages\n"
" -v3|-vvv - also information messages and timestamps\n" " -v2 - also warnings (default level)\n"
" -v4|-vvvv - lots of debug\n" " -v3 - also information messages and timestamps\n"
" -v4 - lots of debug\n"
" --display-stats print out dump/restore stats\n" " --display-stats print out dump/restore stats\n"
"\n" "\n"
"* Memory dumping options:\n" "* Memory dumping options:\n"
......
...@@ -201,10 +201,7 @@ void log_fini(void) ...@@ -201,10 +201,7 @@ void log_fini(void)
void log_set_loglevel(unsigned int level) void log_set_loglevel(unsigned int level)
{ {
if (level == LOG_UNSET) current_loglevel = level;
current_loglevel = DEFAULT_LOGLEVEL;
else
current_loglevel = level;
} }
unsigned int log_get_loglevel(void) unsigned int log_get_loglevel(void)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment