cli: print current thread's error causes, if any, before exiting
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 4 Jul 2019 06:00:18 +0000 (02:00 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Sat, 6 Jul 2019 03:47:50 +0000 (23:47 -0400)
commitf393c19b7abdcc7763d1e6bc045022edeebd283e
tree0f7bc035e3bec1936c4266d3b19d63f3a6a0ec7f
parent2c4f022eddb11b0fd4e164a6fdae169b008f2371
cli: print current thread's error causes, if any, before exiting

This patch makes the CLI print the error causes of the current thread's
error object, if any, before it finally exits.

The causes are printed from the most recent to the least recent. In
other words, the root cause, or deepest cause, is printed at the end of
the list. This is similar to what Python does when it prints a
traceback.

The CLI prints error causes with colors if supported to highlight the
cause's module name, specific properties, file name, and line number.
The CLI prints the messages indented with two spaces and folded on the
terminal's current width if available, otherwise on 80 columns.

You can test the output with

    babeltrace2 $(uuidgen)

This prints something like:

    ERROR:    [Babeltrace CLI] (babeltrace2.c:2531)
      Cannot create components.
    CAUSED BY [Babeltrace CLI] (babeltrace2.c:2355)
      Cannot create component: plugin-name="ctf", comp-cls-name="fs",
      comp-cls-type=0, comp-name="source-ctf-fs"
    CAUSED BY [Babeltrace library] (graph.c:1336)
      Component initialization method failed: status=ERROR,
      comp-addr=0x5590750b8fa0, comp-name="source-ctf-fs",
      comp-log-level=BT_LOGGING_LEVEL_WARN,
      comp-class-type=BT_COMPONENT_CLASS_TYPE_SOURCE, comp-class-name="fs",
      comp-class-partial-descr="Read CTF traces from the file sy",
      comp-class-is-frozen=0, comp-class-so-handle-addr=0x5590750b2aa0,
      comp-class-so-handle-path="babeltrace2/plugins/babeltrace-plugin-ctf.so",
      comp-input-port-count=0, comp-output-port-count=0
    CAUSED BY [source-ctf-fs: 'source.ctf.fs'] (fs.c:1320)
      No CTF traces recursively found in
      `6419ec89-991d-4cf7-ab7f-b143a9901562`.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ib8101e097acf98db305775ac5b90f4eb006ce4ff
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1622
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
src/cli/babeltrace2.c
This page took 0.024905 seconds and 4 git commands to generate.