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>
13 #include "cfg-error-reporting.hpp"
14 #include "cfg-logging.hpp"
17 * Logs with the error level using the configuration `_log_cfg` and
18 * appends a cause to the error of the current thread.
20 #define BT_CLOGE_APPEND_CAUSE_EX(_log_cfg, _fmt, ...) \
22 BT_CLOGE_EX((_log_cfg), _fmt, ##__VA_ARGS__); \
23 BT_APPEND_CAUSE_EX((_log_cfg), _fmt, ##__VA_ARGS__); \
26 #define BT_CLOGE_APPEND_CAUSE(_fmt, ...) \
27 BT_CLOGE_APPEND_CAUSE_EX((BT_CLOG_CFG), _fmt, ##__VA_ARGS__)
30 * Logs with the error level using the configuration `_log_cfg` and
31 * appends a cause to the error of the current thread.
33 #define BT_CLOGE_STR_APPEND_CAUSE_EX(_log_cfg, _str) \
35 BT_CLOGE_STR_EX((_log_cfg), _str); \
36 BT_APPEND_CAUSE_EX((_log_cfg), "%s", _str); \
39 #define BT_CLOGE_STR_APPEND_CAUSE(_str) BT_CLOGE_STR_APPEND_CAUSE_EX((BT_CLOG_CFG), _str)
42 * Logs an errno message with the error level, using the configuration
43 * `_log_cfg`, having the initial message `_init_msg`, and appends a
44 * cause to the error of the current thread.
46 #define BT_CLOGE_ERRNO_APPEND_CAUSE_EX(_log_cfg, _init_msg, _fmt, ...) \
48 BT_CLOGE_ERRNO_EX((_log_cfg), _init_msg, _fmt, ##__VA_ARGS__); \
49 BT_APPEND_CAUSE_ERRNO_EX((_log_cfg), _init_msg, _fmt, ##__VA_ARGS__); \
52 #define BT_CLOGE_ERRNO_APPEND_CAUSE(_init_msg, _fmt, ...) \
53 BT_CLOGE_ERRNO_APPEND_CAUSE_EX((BT_CLOG_CFG), _init_msg, _fmt, ##__VA_ARGS__)
56 * Logs memory bytes with the error level using the configuration
57 * `_log_cfg` and appends a cause to the error of the current thread.
59 #define BT_CLOGE_MEM_APPEND_CAUSE_EX(_log_cfg, _data, _data_sz, _fmt, ...) \
61 BT_CLOGE_MEM_EX((_log_cfg), (_data), (_data_sz), _fmt, ##__VA_ARGS__); \
62 BT_APPEND_CAUSE_EX((_log_cfg), _fmt, ##__VA_ARGS__); \
65 #define BT_CLOGE_MEM_APPEND_CAUSE(_data, _data_sz, _fmt, ...) \
66 BT_CLOGE_MEM_APPEND_CAUSE_EX((BT_CLOG_CFG), (_data), (_data_sz), _fmt, ##__VA_ARGS__)
68 #endif /* BABELTRACE_CPP_COMMON_CFG_LOGGING_ERROR_REPORTING_HPP */