cli: apply log levels (`--log-level` option) to leftovers
authorSimon Marchi <simon.marchi@efficios.com>
Thu, 1 Aug 2019 22:43:31 +0000 (18:43 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Sat, 3 Aug 2019 14:21:39 +0000 (10:21 -0400)
commit1b2b6649155543b87bca6cca9b7fcafc5900dc43
tree07391ada07468e39fae5c5625552bc06b106ad8a
parent1ead9076477cc6be07b0c48ce02fa40e49ddc2f0
cli: apply log levels (`--log-level` option) to leftovers

It is currently not possible to apply --log-level after a leftover.

This patch proposes a way to allow it and to deal with the ambiguity
that it poses.

In the simple case, we have:

    babeltrace2 my-traces --log-level=TRACE

All source components auto-discovered from the `my-traces` leftover will
have the TRACE log level.

If we have more than one leftover, but _no_ cross-leftover grouping,
then it is also intuitive:

    babeltrace2 my-traces-1 --log-level=TRACE my-traces-2 --log-level=DEBUG

... all source components discovered from `my-traces-1` will have log
level TRACE and all source components discovered from `my-traces-2` will
have log level DEBUG.

It becomes less obvious when components are given inputs coming from
multiple leftovers (because of the auto-discovery grouping feature):
which log level do they receive?  For example, if the following line:

    babeltrace2 my-traces-1 --log-level=TRACE my-traces-2 --log-level=DEBUG

leads to these components getting instantiated, with these inputs:

 * Source component X with inputs `my-traces-1/x` and `my-traces-2/x`.
 * Source component Y with input `my-traces-1/y`

In this case, each component receives (on the `run` command line) the
log level options of all leftovers that contributed to its inputs, in
the same order as they are provided on the command line.  The resulting
`run` command line for the example above could therefore look like:

    ... --component x:src.my.comp --log-level=TRACE --log-level=DEBUG \
        --component y:src.my.comp --log-level=TRACE

resulting in these effective log levels:

 * Source component X: log level DEBUG
 * Source component Y: log level TRACE

Change-Id: I5e1bf9e1b4dd139ff7900d81b302a1eda72fb37f
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1810
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
14 files changed:
src/cli/babeltrace2-cfg-cli-args.c
tests/cli/convert/test_auto_source_discovery_log_level [new file with mode: 0755]
tests/cli/convert/test_auto_source_discovery_params
tests/cli/convert/test_convert_args
tests/data/cli/convert/auto-source-discovery-params-log-level/bt_plugin_test.py [new file with mode: 0644]
tests/data/cli/convert/auto-source-discovery-params-log-level/dir-a/aaa [new file with mode: 0644]
tests/data/cli/convert/auto-source-discovery-params-log-level/dir-ab/aaa [new file with mode: 0644]
tests/data/cli/convert/auto-source-discovery-params-log-level/dir-ab/bbb [new file with mode: 0644]
tests/data/cli/convert/auto-source-discovery-params-log-level/dir-b/bbb [new file with mode: 0644]
tests/data/cli/convert/auto-source-discovery-params/bt_plugin_test.py [deleted file]
tests/data/cli/convert/auto-source-discovery-params/dir-a/aaa [deleted file]
tests/data/cli/convert/auto-source-discovery-params/dir-ab/aaa [deleted file]
tests/data/cli/convert/auto-source-discovery-params/dir-ab/bbb [deleted file]
tests/data/cli/convert/auto-source-discovery-params/dir-b/bbb [deleted file]
This page took 0.02632 seconds and 4 git commands to generate.