cli: set log levels earlier
authorSimon Marchi <simon.marchi@efficios.com>
Wed, 14 Aug 2019 20:47:26 +0000 (16:47 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Sat, 17 Aug 2019 00:12:13 +0000 (20:12 -0400)
commitebddaeb83b3ec9f08ad1e6b4bc6bc771a8f1a655
tree896a27eef118ee929212ee984a20680ef62b7057
parent70dfe5e41a18dc2225d1b80dccd547050ee5df35
cli: set log levels earlier

The problem this patch is aiming to solve is that the effective log
level is not set when executing bt_config_convert_from_args.  For
example, bt_python_bindings_bt2_log_level is still NONE, only to be set
later.  So if Python plugin fails to be imported during the auto source
discovery phase, nothing will be logged, making debugging quite
difficult.  Any argument passed (top level --log-level, --debug or
--verbose) won't help because they will take effect later, when we call
set_auto_log_levels.

This patch moves the call to set_auto_log_levels earlier, as soon as we
know what the default log level will be.  For all commands but
`convert`, it is after we are done parsing the top-level arguments.  The
default log level will be the most verbose any --debug, --verbose or
--log-level argument passed.

With the `convert` command, it is possible to pass --debug and
--verbose, with the same effect as the top-level equivalents.  So for
this command, we call set_auto_log_levels just after parsing its
arguments.

The --debug argument sets the log level to TRACE and the --verbose
argument sets it to INFO.  If more than one of --debug, --verbose and
--log-level are specified, the most verbose level of all specified
arguments is chosen.

Note that the --log-level argument of the convert command is not the
same as the top-level's --log-level argument.  The argument of the
convert command sets the --log-level of a specific component or
auto-source-discovery input.

The behavior of the environment variables LIBBABELTRACE2_INIT_LOG_LEVEL,
BABELTRACE_PLUGIN_CTF_METADATA_LOG_LEVEL and
BABELTRACE_PYTHON_BT2_LOG_LEVEL is kept.  If they are specified, they
force the log level of the corresponding subsystem, overriding the
log level specified on the command line.

Change-Id: I9ac558737df4789fc8f5bd8d0240887b3b11b295
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1935
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
src/cli/Makefile.am
src/cli/babeltrace2-cfg-cli-args.c
src/cli/babeltrace2-cfg.h
src/cli/babeltrace2-log-level.c [new file with mode: 0644]
src/cli/babeltrace2-log-level.h [new file with mode: 0644]
src/cli/babeltrace2.c
This page took 0.025119 seconds and 4 git commands to generate.