2 * SPDX-License-Identifier: MIT
4 * Copyright (c) 2022 Simon Marchi <simon.marchi@efficios.com>
5 * Copyright (c) 2022 Philippe Proulx <eeppeliteloop@gmail.com>
8 #ifndef BABELTRACE_CPP_COMMON_CFG_LOGGING_ERROR_REPORTING_HPP
9 #define BABELTRACE_CPP_COMMON_CFG_LOGGING_ERROR_REPORTING_HPP
11 #include <babeltrace2/babeltrace.h>
12 #include "cfg-logging.hpp"
13 #include "cfg-error-reporting.hpp"
16 * Logs with the error level using the configuration `_log_cfg` and
17 * appends a cause to the error of the current thread.
19 #define BT_CLOGE_APPEND_CAUSE_EX(_log_cfg, _fmt, ...) \
21 BT_CLOGE_EX((_log_cfg), _fmt, ##__VA_ARGS__); \
22 BT_APPEND_CAUSE_EX((_log_cfg), _fmt, ##__VA_ARGS__); \
25 #define BT_CLOGE_APPEND_CAUSE(_fmt, ...) \
26 BT_CLOGE_APPEND_CAUSE_EX((BT_CLOG_CFG), _fmt, ##__VA_ARGS__)
29 * Logs with the error level using the configuration `_log_cfg` and
30 * appends a cause to the error of the current thread.
32 #define BT_CLOGE_STR_APPEND_CAUSE_EX(_log_cfg, _str) \
34 BT_CLOGE_STR_EX((_log_cfg), _str); \
35 BT_APPEND_CAUSE_EX((_log_cfg), "%s", _str); \
38 #define BT_CLOGE_STR_APPEND_CAUSE(_str) BT_CLOGE_STR_APPEND_CAUSE_EX((BT_CLOG_CFG), _str)
41 * Logs an errno message with the error level, using the configuration
42 * `_log_cfg`, having the initial message `_init_msg`, and appends a
43 * cause to the error of the current thread.
45 #define BT_CLOGE_ERRNO_APPEND_CAUSE_EX(_log_cfg, _init_msg, _fmt, ...) \
47 BT_CLOGE_ERRNO_EX((_log_cfg), _init_msg, _fmt, ##__VA_ARGS__); \
48 BT_APPEND_CAUSE_ERRNO_EX((_log_cfg), _init_msg, _fmt, ##__VA_ARGS__); \
51 #define BT_CLOGE_ERRNO_APPEND_CAUSE(_init_msg, _fmt, ...) \
52 BT_CLOGE_ERRNO_APPEND_CAUSE_EX((BT_CLOG_CFG), _init_msg, _fmt, ##__VA_ARGS__)
55 * Logs memory bytes with the error level using the configuration
56 * `_log_cfg` and appends a cause to the error of the current thread.
58 #define BT_CLOGE_MEM_APPEND_CAUSE_EX(_log_cfg, _data, _data_sz, _fmt, ...) \
60 BT_CLOGE_MEM_EX((_log_cfg), (_data), (_data_sz), _fmt, ##__VA_ARGS__); \
61 BT_APPEND_CAUSE_EX((_log_cfg), _fmt, ##__VA_ARGS__); \
64 #define BT_CLOGE_MEM_APPEND_CAUSE(_data, _data_sz, _fmt, ...) \
65 BT_CLOGE_MEM_APPEND_CAUSE_EX((BT_CLOG_CFG), (_data), (_data_sz), _fmt, ##__VA_ARGS__)
67 #endif /* BABELTRACE_CPP_COMMON_CFG_LOGGING_ERROR_REPORTING_HPP */