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)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 18 Jul 2019 15:53:34 +0000 (11:53 -0400)
commit20bf8ef72557690c315a616e928dd43e8486117a
tree133b558dd5e198db821e0c550472673e8dbf5389
parentc449a4d71b9ef8ce3e175dc6b70b27e58f41a684
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.046472 seconds and 4 git commands to generate.