cpp-common/bt2c/logging.hpp: add text location logging
authorSimon Marchi <simon.marchi@efficios.com>
Mon, 27 May 2024 14:08:01 +0000 (10:08 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Wed, 4 Sep 2024 19:05:14 +0000 (15:05 -0400)
commitc2797c1468f949c673bb5daa390c1983614e9f7b
tree1f4befd699de5d121de051de3c268010718fe825
parent850d66dc51d3bf0afefbafb60dfd8beb655a5cf8
cpp-common/bt2c/logging.hpp: add text location logging

This patch makes a `bt2c::Logger` instance hold a text location string
format (`bt2c::TextLocStrFmt`) and adds the logTextLoc(),
logErrorTextLocAndThrow(), and logErrorTextLocAndRethrow() methods which
accept a text location (`bt2c::TextLoc`) and make its equivalent
formatted string a prefix of the log message, for example:

    [13:38 @ 4776 bytes] Failed to parse this and that.

Because the text location string format member is specific to the text
location logging methods, it has an arbitrary default value
(`TextLocStrFmt::LineColNosAndOffset`) at construction time. You may
change it at any time with the textLocStrFmt() method.

Also adding the typical BT_CPPLOG*() macros to use the new methods with
`__FILE__`, `__func__`, and `__LINE__`.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I74c716929da2ef4cdd915c97811a466475539514
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12680
src/cpp-common/bt2c/logging.hpp
This page took 0.023525 seconds and 4 git commands to generate.