# SPDX-License-Identifier: MIT
EXTRA_DIST = bt2 \
+ cfg-error-reporting-throw.hpp \
+ cfg-error-reporting.hpp \
+ cfg-logging-error-reporting-throw.hpp \
+ cfg-logging-error-reporting.hpp \
+ cfg-logging.hpp \
exc.hpp \
log-cfg.hpp \
nlohmann/json.hpp \
--- /dev/null
+/*
+ * SPDX-License-Identifier: MIT
+ *
+ * Copyright (c) 2022 Francis Deslauriers <francis.deslauriers@efficios.com>
+ * Copyright (c) 2022 Simon Marchi <simon.marchi@efficios.com>
+ * Copyright (c) 2022 Philippe Proulx <eeppeliteloop@gmail.com>
+ */
+
+#ifndef BABELTRACE_CPP_COMMON_CFG_ERROR_REPORTING_THROW_HPP
+#define BABELTRACE_CPP_COMMON_CFG_ERROR_REPORTING_THROW_HPP
+
+#include <babeltrace2/babeltrace.h>
+#include "cfg-error-reporting.hpp"
+
+/*
+ * Appends a cause to the error of the current thread using the
+ * configuration `_log_cfg` and throws an instance of `_exc_cls`.
+ */
+#define BT_APPEND_CAUSE_AND_THROW_EX(_log_cfg, _exc_cls, _fmt, ...) \
+ do { \
+ BT_APPEND_CAUSE_EX((_log_cfg), _fmt, ##__VA_ARGS__); \
+ throw _exc_cls {}; \
+ } while (false)
+
+#define BT_APPEND_CAUSE_AND_THROW(_exc_cls, _fmt, ...) \
+ BT_APPEND_CAUSE_AND_THROW_EX((BT_CLOG_CFG), _exc_cls, _fmt, ##__VA_ARGS__)
+
+/*
+ * Appends a cause to the error of the current thread using the
+ * configuration `_log_cfg` and rethrows.
+ */
+#define BT_APPEND_CAUSE_AND_RETHROW_EX(_log_cfg, _fmt, ...) \
+ do { \
+ BT_APPEND_CAUSE_EX((_log_cfg), _fmt, ##__VA_ARGS__); \
+ throw;
+}
+while (false)
+
+#define BT_APPEND_CAUSE_AND_RETHROW(_fmt, ...) \
+ BT_APPEND_CAUSE_AND_RETHROW_EX((BT_CLOG_CFG), _fmt, ##__VA_ARGS__)
+
+/*
+ * Appends a cause to the error of the current thread using the
+ * configuration `_log_cfg` and throws an instance of `_exc_cls`.
+ */
+#define BT_APPEND_CAUSE_STR_AND_THROW_EX(_log_cfg, _exc_cls, _str) \
+ do { \
+ BT_APPEND_CAUSE_STR_EX((_log_cfg), _str); \
+ throw _exc_cls {}; \
+ } while (false)
+
+#define BT_APPEND_CAUSE_STR_AND_THROW(_exc_cls, _str) \
+ BT_APPEND_CAUSE_STR_AND_THROW_EX((BT_CLOG_CFG), _exc_cls, _str)
+
+/*
+ * Appends a cause to the error of the current thread using the
+ * configuration `_log_cfg` and rethrows.
+ */
+#define BT_APPEND_CAUSE_STR_AND_RETHROW_EX(_log_cfg, _str) \
+ do { \
+ BT_APPEND_CAUSE_STR_EX((_log_cfg), _str); \
+ throw; \
+ } while (false)
+
+#define BT_APPEND_CAUSE_STR_AND_RETHROW(_str) \
+ BT_APPEND_CAUSE_STR_AND_RETHROW_EX((BT_CLOG_CFG), _str)
+
+/*
+ * Appends a cause with an errno message to the error of the current
+ * thread, using the initial message `_init_msg` and the configuration
+ * `_log_cfg`, and throws an instance of `_exc_cls`.
+ */
+#define BT_APPEND_CAUSE_ERRNO_AND_THROW_EX(_log_cfg, _exc_cls, _init_msg, _fmt, ...) \
+ do { \
+ BT_APPEND_CAUSE_ERRNO_EX((_log_cfg), _init_msg, _fmt, ##__VA_ARGS__); \
+ throw _exc_cls {}; \
+ } while (false)
+
+#define BT_APPEND_CAUSE_ERRNO_AND_THROW(_exc_cls, _init_msg, _fmt, ...) \
+ BT_APPEND_CAUSE_ERRNO_AND_THROW_EX((BT_CLOG_CFG), _exc_cls, _init_msg, _fmt, ##__VA_ARGS__)
+
+/*
+ * Appends a cause with an errno message to the error of the current
+ * thread, using the initial message `_init_msg` and the configuration
+ * `_log_cfg`, and rethrows.
+ */
+#define BT_APPEND_CAUSE_ERRNO_AND_RETHROW_EX(_log_cfg, _init_msg, _fmt, ...) \
+ do { \
+ BT_APPEND_CAUSE_ERRNO_EX((_log_cfg), _init_msg, _fmt, ##__VA_ARGS__); \
+ throw; \
+ } while (false)
+
+#define BT_APPEND_CAUSE_ERRNO_AND_RETHROW(_init_msg, _fmt, ...) \
+ BT_APPEND_CAUSE_ERRNO_AND_RETHROW_EX((BT_CLOG_CFG), _init_msg, _fmt, ##__VA_ARGS__)
+
+#endif /* BABELTRACE_CPP_COMMON_CFG_ERROR_REPORTING_THROW_HPP */
--- /dev/null
+/*
+ * SPDX-License-Identifier: MIT
+ *
+ * Copyright (c) 2022 Simon Marchi <simon.marchi@efficios.com>
+ * Copyright (c) 2022 Philippe Proulx <eeppeliteloop@gmail.com>
+ */
+
+#ifndef BABELTRACE_CPP_COMMON_CFG_ERROR_REPORTING_HPP
+#define BABELTRACE_CPP_COMMON_CFG_ERROR_REPORTING_HPP
+
+#include <babeltrace2/babeltrace.h>
+#include "cfg-logging.hpp"
+
+/*
+ * Appends a cause to the error of the current thread using the logging
+ * configuration `_log_cfg`.
+ */
+#define BT_APPEND_CAUSE_EX(_log_cfg, _fmt, ...) \
+ do { \
+ if ((_log_cfg).selfMsgIter()) { \
+ BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_MESSAGE_ITERATOR((_log_cfg).selfMsgIter(), \
+ _fmt, ##__VA_ARGS__); \
+ } else if ((_log_cfg).selfComp()) { \
+ BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_COMPONENT((_log_cfg).selfComp(), _fmt, \
+ ##__VA_ARGS__); \
+ } else if ((_log_cfg).selfCompCls()) { \
+ BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_COMPONENT_CLASS((_log_cfg).selfCompCls(), \
+ _fmt, ##__VA_ARGS__); \
+ } else { \
+ BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_UNKNOWN((_log_cfg).moduleName(), _fmt, \
+ ##__VA_ARGS__); \
+ } \
+ } while (false)
+
+#define BT_APPEND_CAUSE(_fmt, ...) BT_APPEND_CAUSE_EX((BT_CLOG_CFG), _fmt, ##__VA_ARGS__)
+
+/*
+ * Appends a cause to the error of the current thread using the logging
+ * configuration `_log_cfg`.
+ */
+#define BT_APPEND_CAUSE_STR_EX(_log_cfg, _str) BT_APPEND_CAUSE_EX((_log_cfg), "%s", _str)
+
+#define BT_APPEND_CAUSE_STR(_str) BT_APPEND_CAUSE_STR_EX((BT_CLOG_CFG), _str)
+
+/*
+ * Appends a cause with an errno message to the error of the current
+ * thread using the logging configuration `_log_cfg`.
+ */
+#define BT_APPEND_CAUSE_ERRNO_EX(_log_cfg, _init_msg, _fmt, ...) \
+ do { \
+ const auto errStr = g_strerror(errno); \
+ BT_APPEND_CAUSE_EX((_log_cfg), "%s: %s" _fmt, _init_msg, errStr, ##__VA_ARGS__); \
+ } while (false)
+
+#define BT_APPEND_CAUSE_ERRNO(_init_msg, _fmt, ...) \
+ BT_APPEND_CAUSE_EX((BT_CLOG_CFG), _init_msg, _fmt, ##__VA_ARGS__)
+
+#endif /* BABELTRACE_CPP_COMMON_CFG_ERROR_REPORTING_HPP */
--- /dev/null
+/*
+ * SPDX-License-Identifier: MIT
+ *
+ * Copyright (c) 2022 Francis Deslauriers <francis.deslauriers@efficios.com>
+ * Copyright (c) 2022 Simon Marchi <simon.marchi@efficios.com>
+ * Copyright (c) 2022 Philippe Proulx <eeppeliteloop@gmail.com>
+ */
+
+#ifndef BABELTRACE_CPP_COMMON_CFG_LOGGING_ERROR_REPORTING_THROW_HPP
+#define BABELTRACE_CPP_COMMON_CFG_LOGGING_ERROR_REPORTING_THROW_HPP
+
+#include <babeltrace2/babeltrace.h>
+#include "cfg-logging-error-reporting.hpp"
+
+/*
+ * Logs with the error level using the configuration `_log_cfg`, appends
+ * a cause to the error of the current thread, and throws an instance of
+ * `_exc_cls`.
+ */
+#define BT_CLOGE_APPEND_CAUSE_AND_THROW_EX(_log_cfg, _exc_cls, _fmt, ...) \
+ do { \
+ BT_CLOGE_APPEND_CAUSE_EX((_log_cfg), _fmt, ##__VA_ARGS__); \
+ throw _exc_cls {}; \
+ } while (false)
+
+#define BT_CLOGE_APPEND_CAUSE_AND_THROW(_exc_cls, _fmt, ...) \
+ BT_CLOGE_APPEND_CAUSE_AND_THROW_EX((BT_CLOG_CFG), _exc_cls, _fmt, ##__VA_ARGS__)
+
+/*
+ * Logs with the error level using the configuration `_log_cfg`, appends
+ * a cause to the error of the current thread, and rethrows.
+ */
+#define BT_CLOGE_APPEND_CAUSE_AND_RETHROW_EX(_log_cfg, _fmt, ...) \
+ do { \
+ BT_CLOGE_APPEND_CAUSE_EX((_log_cfg), _fmt, ##__VA_ARGS__); \
+ throw; \
+ } while (false)
+
+#define BT_CLOGE_APPEND_CAUSE_AND_RETHROW(_fmt, ...) \
+ BT_CLOGE_APPEND_CAUSE_AND_RETHROW_EX((BT_CLOG_CFG), _fmt, ##__VA_ARGS__)
+
+/*
+ * Logs with the error level using the configuration `_log_cfg`, appends
+ * a cause to the error of the current thread, and throws an instance of
+ * `_exc_cls`.
+ */
+#define BT_CLOGE_STR_APPEND_CAUSE_AND_THROW_EX(_log_cfg, _exc_cls, _str) \
+ do { \
+ BT_CLOGE_STR_APPEND_CAUSE_EX((_log_cfg), _str); \
+ throw _exc_cls {}; \
+ } while (false)
+
+#define BT_CLOGE_STR_APPEND_CAUSE_AND_THROW(_exc_cls, _str) \
+ BT_CLOGE_APPEND_CAUSE_AND_THROW_EX((BT_CLOG_CFG), _exc_cls, _str)
+
+/*
+ * Logs with the error level using the configuration `_log_cfg`, appends
+ * a cause to the error of the current thread, and rethrows.
+ */
+#define BT_CLOGE_STR_APPEND_CAUSE_AND_RETHROW_EX(_log_cfg, _str) \
+ do { \
+ BT_CLOGE_STR_APPEND_CAUSE_EX((_log_cfg), _str); \
+ throw; \
+ } while (false)
+
+#define BT_CLOGE_STR_APPEND_CAUSE_AND_RETHROW(_str) \
+ BT_CLOGE_APPEND_CAUSE_AND_RETHROW_EX((BT_CLOG_CFG), _str)
+
+/*
+ * Logs an errno message with the error level, using the configuration
+ * `_log_cfg`, having the initial message `_init_msg`, appends a cause
+ * to the error of the current thread, and throws an instance of
+ * `_exc_cls`.
+ */
+#define BT_CLOGE_ERRNO_APPEND_CAUSE_AND_THROW_EX(_log_cfg, _exc_cls, _init_msg, _fmt, ...) \
+ do { \
+ BT_CLOGE_ERRNO_APPEND_CAUSE_EX((_log_cfg), _init_msg, _fmt, ##__VA_ARGS__); \
+ throw _exc_cls {}; \
+ } while (false)
+
+#define BT_CLOGE_ERRNO_APPEND_CAUSE_AND_THROW(_exc_cls, _init_msg, _fmt, ...) \
+ BT_CLOGE_ERRNO_APPEND_CAUSE_AND_THROW_EX((BT_CLOG_CFG), _exc_cls, _init_msg, _fmt, \
+ ##__VA_ARGS__)
+
+/*
+ * Logs an errno message with the error level, using the configuration
+ * `_log_cfg`, having the initial message `_init_msg`, appends a cause
+ * to the error of the current thread, and rethrows.
+ */
+#define BT_CLOGE_ERRNO_APPEND_CAUSE_AND_RETHROW_EX(_log_cfg, _init_msg, _fmt, ...) \
+ do { \
+ BT_CLOGE_ERRNO_APPEND_CAUSE_EX((_log_cfg), _init_msg, _fmt, ##__VA_ARGS__); \
+ throw; \
+ } while (false)
+
+#define BT_CLOGE_ERRNO_APPEND_CAUSE_AND_RETHROW(_init_msg, _fmt, ...) \
+ BT_CLOGE_ERRNO_APPEND_CAUSE_AND_RETHROW_EX((BT_CLOG_CFG), _init_msg, _fmt, ##__VA_ARGS__)
+
+/*
+ * Logs memory bytes with the error level using the configuration
+ * `_log_cfg`, appends a cause to the error of the current thread, and
+ * throws an instance of `_exc_cls`.
+ */
+#define BT_CLOGE_MEM_APPEND_CAUSE_AND_THROW_EX(_log_cfg, _exc_cls, _data, _data_sz, _fmt, ...) \
+ do { \
+ BT_CLOGE_MEM_APPEND_CAUSE_EX((_log_cfg), (_data), (_data_sz), _fmt, ##__VA_ARGS__); \
+ throw _exc_cls {}; \
+ } while (false)
+
+#define BT_CLOGE_MEM_APPEND_CAUSE_AND_THROW(_exc_cls, _data, _data_sz, _fmt, ...) \
+ BT_CLOGE_MEM_APPEND_CAUSE_AND_THROW_EX((BT_CLOG_CFG), _exc_cls, (_data), (_data_sz), _fmt, \
+ ##__VA_ARGS__)
+
+/*
+ * Logs memory bytes with the error level using the configuration
+ * `_log_cfg`, appends a cause to the error of the current thread, and
+ * rethrows.
+ */
+#define BT_CLOGE_MEM_APPEND_CAUSE_AND_RETHROW_EX(_log_cfg, _data, _data_sz, _fmt, ...) \
+ do { \
+ BT_CLOGE_MEM_APPEND_CAUSE_EX((_log_cfg), (_data), (_data_sz), _fmt, ##__VA_ARGS__); \
+ throw; \
+ } while (false)
+
+#define BT_CLOGE_MEM_APPEND_CAUSE_AND_RETHROW(_data, _data_sz, _fmt, ...) \
+ BT_CLOGE_MEM_APPEND_CAUSE_AND_RETHROW_EX((BT_CLOG_CFG), (_data), (_data_sz), _fmt, \
+ ##__VA_ARGS__)
+
+#endif /* BABELTRACE_CPP_COMMON_CFG_LOGGING_ERROR_REPORTING_THROW_HPP */
--- /dev/null
+/*
+ * SPDX-License-Identifier: MIT
+ *
+ * Copyright (c) 2022 Simon Marchi <simon.marchi@efficios.com>
+ * Copyright (c) 2022 Philippe Proulx <eeppeliteloop@gmail.com>
+ */
+
+#ifndef BABELTRACE_CPP_COMMON_CFG_LOGGING_ERROR_REPORTING_HPP
+#define BABELTRACE_CPP_COMMON_CFG_LOGGING_ERROR_REPORTING_HPP
+
+#include <babeltrace2/babeltrace.h>
+#include "cfg-logging.hpp"
+#include "cfg-error-reporting.hpp"
+
+/*
+ * Logs with the error level using the configuration `_log_cfg` and
+ * appends a cause to the error of the current thread.
+ */
+#define BT_CLOGE_APPEND_CAUSE_EX(_log_cfg, _fmt, ...) \
+ do { \
+ BT_CLOGE_EX((_log_cfg), _fmt, ##__VA_ARGS__); \
+ BT_APPEND_CAUSE_EX((_log_cfg), _fmt, ##__VA_ARGS__); \
+ } while (false)
+
+#define BT_CLOGE_APPEND_CAUSE(_fmt, ...) \
+ BT_CLOGE_APPEND_CAUSE_EX((BT_CLOG_CFG), _fmt, ##__VA_ARGS__)
+
+/*
+ * Logs with the error level using the configuration `_log_cfg` and
+ * appends a cause to the error of the current thread.
+ */
+#define BT_CLOGE_STR_APPEND_CAUSE_EX(_log_cfg, _str) \
+ do { \
+ BT_CLOGE_STR_EX((_log_cfg), _str); \
+ BT_APPEND_CAUSE_EX((_log_cfg), "%s", _str); \
+ } while (false)
+
+#define BT_CLOGE_STR_APPEND_CAUSE(_str) BT_CLOGE_STR_APPEND_CAUSE_EX((BT_CLOG_CFG), _str)
+
+/*
+ * Logs an errno message with the error level, using the configuration
+ * `_log_cfg`, having the initial message `_init_msg`, and appends a
+ * cause to the error of the current thread.
+ */
+#define BT_CLOGE_ERRNO_APPEND_CAUSE_EX(_log_cfg, _init_msg, _fmt, ...) \
+ do { \
+ BT_CLOGE_ERRNO_EX((_log_cfg), _init_msg, _fmt, ##__VA_ARGS__); \
+ BT_APPEND_CAUSE_ERRNO_EX((_log_cfg), _init_msg, _fmt, ##__VA_ARGS__); \
+ } while (false)
+
+#define BT_CLOGE_ERRNO_APPEND_CAUSE(_init_msg, _fmt, ...) \
+ BT_CLOGE_ERRNO_APPEND_CAUSE_EX((BT_CLOG_CFG), _init_msg, _fmt, ##__VA_ARGS__)
+
+/*
+ * Logs memory bytes with the error level using the configuration
+ * `_log_cfg` and appends a cause to the error of the current thread.
+ */
+#define BT_CLOGE_MEM_APPEND_CAUSE_EX(_log_cfg, _data, _data_sz, _fmt, ...) \
+ do { \
+ BT_CLOGE_MEM_EX((_log_cfg), (_data), (_data_sz), _fmt, ##__VA_ARGS__); \
+ BT_APPEND_CAUSE_EX((_log_cfg), _fmt, ##__VA_ARGS__); \
+ } while (false)
+
+#define BT_CLOGE_MEM_APPEND_CAUSE(_data, _data_sz, _fmt, ...) \
+ BT_CLOGE_MEM_APPEND_CAUSE_EX((BT_CLOG_CFG), (_data), (_data_sz), _fmt, ##__VA_ARGS__)
+
+#endif /* BABELTRACE_CPP_COMMON_CFG_LOGGING_ERROR_REPORTING_HPP */
--- /dev/null
+/*
+ * SPDX-License-Identifier: MIT
+ *
+ * Copyright (c) 2022 Philippe Proulx <eeppeliteloop@gmail.com>
+ */
+
+#ifndef BABELTRACE_CPP_COMMON_CFG_LOGGING_HPP
+#define BABELTRACE_CPP_COMMON_CFG_LOGGING_HPP
+
+#ifdef BT_CLOG_CFG
+# ifdef BT_LOG_OUTPUT_LEVEL
+# error `BT_LOG_OUTPUT_LEVEL` may not be defined when `BT_CLOG_CFG` is.
+# endif
+# define BT_LOG_OUTPUT_LEVEL ((BT_CLOG_CFG).logLevel())
+#endif
+
+#include <babeltrace2/babeltrace.h>
+#include "logging/log.h"
+
+#define _BT_CLOG_OBJ_FMT_PREFIX "[%s] "
+
+/*
+ * Logs with the level `_lvl` using the configuration `_log_cfg`.
+ */
+#define BT_CLOG_EX(_lvl, _log_cfg, _fmt, ...) \
+ if (BT_LOG_ON_CUR_LVL(_lvl, (_log_cfg).logLevel())) { \
+ if ((_log_cfg).selfComp()) { \
+ _bt_log_write((_lvl), _BT_LOG_TAG, _BT_CLOG_OBJ_FMT_PREFIX _fmt, \
+ (_log_cfg).compName(), ##__VA_ARGS__); \
+ } else if ((_log_cfg).compCls()) { \
+ _bt_log_write((_lvl), _BT_LOG_TAG, _BT_CLOG_OBJ_FMT_PREFIX _fmt, \
+ (_log_cfg).compClsName(), ##__VA_ARGS__); \
+ } else { \
+ _bt_log_write((_lvl), _BT_LOG_TAG, _fmt, ##__VA_ARGS__); \
+ } \
+ }
+
+#define BT_CLOGF_EX(_log_cfg, _fmt, ...) BT_CLOG_EX(BT_LOG_FATAL, (_log_cfg), _fmt, ##__VA_ARGS__)
+#define BT_CLOGE_EX(_log_cfg, _fmt, ...) BT_CLOG_EX(BT_LOG_ERROR, (_log_cfg), _fmt, ##__VA_ARGS__)
+#define BT_CLOGW_EX(_log_cfg, _fmt, ...) BT_CLOG_EX(BT_LOG_WARNING, (_log_cfg), _fmt, ##__VA_ARGS__)
+#define BT_CLOGI_EX(_log_cfg, _fmt, ...) BT_CLOG_EX(BT_LOG_INFO, (_log_cfg), _fmt, ##__VA_ARGS__)
+#define BT_CLOGD_EX(_log_cfg, _fmt, ...) BT_CLOG_EX(BT_LOG_DEBUG, (_log_cfg), _fmt, ##__VA_ARGS__)
+#define BT_CLOGT_EX(_log_cfg, _fmt, ...) BT_CLOG_EX(BT_LOG_TRACE, (_log_cfg), _fmt, ##__VA_ARGS__)
+#define BT_CLOG(_lvl, _fmt, ...) BT_CLOG_EX((_lvl), (BT_CLOG_CFG), _fmt, ##__VA_ARGS__)
+#define BT_CLOGF(_fmt, ...) BT_CLOG(BT_LOG_FATAL, _fmt, ##__VA_ARGS__)
+#define BT_CLOGE(_fmt, ...) BT_CLOG(BT_LOG_ERROR, _fmt, ##__VA_ARGS__)
+#define BT_CLOGW(_fmt, ...) BT_CLOG(BT_LOG_WARNING, _fmt, ##__VA_ARGS__)
+#define BT_CLOGI(_fmt, ...) BT_CLOG(BT_LOG_INFO, _fmt, ##__VA_ARGS__)
+#define BT_CLOGD(_fmt, ...) BT_CLOG(BT_LOG_DEBUG, _fmt, ##__VA_ARGS__)
+#define BT_CLOGT(_fmt, ...) BT_CLOG(BT_LOG_TRACE, _fmt, ##__VA_ARGS__)
+
+/*
+ * Logs with the level `_lvl` using the configuration `_log_cfg`.
+ */
+#define BT_CLOG_STR_EX(_lvl, _log_cfg, _str) BT_CLOG_EX((_lvl), (_log_cfg), "%s", _str)
+
+#define BT_CLOGF_STR_EX(_log_cfg, _str) BT_CLOG_STR_EX(BT_LOG_FATAL, (_log_cfg), _str)
+#define BT_CLOGE_STR_EX(_log_cfg, _str) BT_CLOG_STR_EX(BT_LOG_ERROR, (_log_cfg), _str)
+#define BT_CLOGW_STR_EX(_log_cfg, _str) BT_CLOG_STR_EX(BT_LOG_WARNING, (_log_cfg), _str)
+#define BT_CLOGI_STR_EX(_log_cfg, _str) BT_CLOG_STR_EX(BT_LOG_INFO, (_log_cfg), _str)
+#define BT_CLOGD_STR_EX(_log_cfg, _str) BT_CLOG_STR_EX(BT_LOG_DEBUG, (_log_cfg), _str)
+#define BT_CLOGT_STR_EX(_log_cfg, _str) BT_CLOG_STR_EX(BT_LOG_TRACE, (_log_cfg), _str)
+#define BT_CLOG_STR(_lvl, _str) BT_CLOG_STR_EX((_lvl), (BT_CLOG_CFG), _str)
+#define BT_CLOGF_STR(_str) BT_CLOG_STR(BT_LOG_FATAL, _str)
+#define BT_CLOGE_STR(_str) BT_CLOG_STR(BT_LOG_ERROR, _str)
+#define BT_CLOGW_STR(_str) BT_CLOG_STR(BT_LOG_WARNING, _str)
+#define BT_CLOGI_STR(_str) BT_CLOG_STR(BT_LOG_INFO, _str)
+#define BT_CLOGD_STR(_str) BT_CLOG_STR(BT_LOG_DEBUG, _str)
+#define BT_CLOGT_STR(_str) BT_CLOG_STR(BT_LOG_TRACE, _str)
+
+/*
+ * Logs an errno message with the level `_lvl`, using the configuration
+ * `_log_cfg`, and having the initial message `_init_msg`.
+ */
+#define BT_CLOG_ERRNO_EX(_lvl, _log_cfg, _init_msg, _fmt, ...) \
+ if (BT_LOG_ON(_lvl)) { \
+ const auto errStr = g_strerror(errno); \
+ if ((_log_cfg).selfComp()) { \
+ _bt_log_write((_lvl), _BT_LOG_TAG, _BT_CLOG_OBJ_FMT_PREFIX "%s: %s" _fmt, \
+ (_log_cfg).compName(), _init_msg, errStr, ##__VA_ARGS__); \
+ } else if ((_log_cfg).compCls()) { \
+ _bt_log_write((_lvl), _BT_LOG_TAG, _BT_CLOG_OBJ_FMT_PREFIX "%s: %s" _fmt, \
+ (_log_cfg).compClsName(), _init_msg, errStr, ##__VA_ARGS__); \
+ } else { \
+ _bt_log_write((_lvl), _BT_LOG_TAG, "%s: %s" _fmt, _init_msg, errStr, ##__VA_ARGS__); \
+ } \
+ }
+
+#define BT_CLOGF_ERRNO_EX(_log_cfg, _init_msg, _fmt, ...) \
+ BT_CLOG_ERRNO_EX(BT_LOG_FATAL, (_log_cfg), _init_msg, _fmt, ##__VA_ARGS__)
+#define BT_CLOGE_ERRNO_EX(_log_cfg, _init_msg, _fmt, ...) \
+ BT_CLOG_ERRNO_EX(BT_LOG_ERROR, (_log_cfg), _init_msg, _fmt, ##__VA_ARGS__)
+#define BT_CLOGW_ERRNO_EX(_log_cfg, _init_msg, _fmt, ...) \
+ BT_CLOG_ERRNO_EX(BT_LOG_WARNING, (_log_cfg), _init_msg, _fmt, ##__VA_ARGS__)
+#define BT_CLOGI_ERRNO_EX(_log_cfg, _init_msg, _fmt, ...) \
+ BT_CLOG_ERRNO_EX(BT_LOG_INFO, (_log_cfg), _init_msg, _fmt, ##__VA_ARGS__)
+#define BT_CLOGD_ERRNO_EX(_log_cfg, _init_msg, _fmt, ...) \
+ BT_CLOG_ERRNO_EX(BT_LOG_DEBUG, (_log_cfg), _init_msg, _fmt, ##__VA_ARGS__)
+#define BT_CLOGT_ERRNO_EX(_log_cfg, _init_msg, _fmt, ...) \
+ BT_CLOG_ERRNO_EX(BT_LOG_TRACE, (_log_cfg), _init_msg, _fmt, ##__VA_ARGS__)
+#define BT_CLOG_ERRNO(_lvl, _init_msg, _fmt, ...) \
+ BT_CLOG_ERRNO_EX((_lvl), (BT_CLOG_CFG), _init_msg, _fmt, ##__VA_ARGS__)
+#define BT_CLOGF_ERRNO(_init_msg, _fmt, ...) \
+ BT_CLOG_ERRNO(BT_LOG_FATAL, _init_msg, _fmt, ##__VA_ARGS__)
+#define BT_CLOGE_ERRNO(_init_msg, _fmt, ...) \
+ BT_CLOG_ERRNO(BT_LOG_ERROR, _init_msg, _fmt, ##__VA_ARGS__)
+#define BT_CLOGW_ERRNO(_init_msg, _fmt, ...) \
+ BT_CLOG_ERRNO(BT_LOG_WARNING, _init_msg, _fmt, ##__VA_ARGS__)
+#define BT_CLOGI_ERRNO(_init_msg, _fmt, ...) \
+ BT_CLOG_ERRNO(BT_LOG_INFO, _init_msg, _fmt, ##__VA_ARGS__)
+#define BT_CLOGD_ERRNO(_init_msg, _fmt, ...) \
+ BT_CLOG_ERRNO(BT_LOG_DEBUG, _init_msg, _fmt, ##__VA_ARGS__)
+#define BT_CLOGT_ERRNO(_init_msg, _fmt, ...) \
+ BT_CLOG_ERRNO(BT_LOG_TRACE, _init_msg, _fmt, ##__VA_ARGS__)
+
+/*
+ * Logs memory bytes with the level `_lvl` using the configuration
+ * `_log_cfg`.
+ */
+#define BT_CLOG_MEM_EX(_lvl, _log_cfg, _data, _data_sz, _fmt, ...) \
+ if (BT_LOG_ON(_lvl)) { \
+ if ((_log_cfg).selfComp()) { \
+ _bt_log_write_mem((_lvl), _BT_LOG_TAG, (_data), (_data_sz), \
+ _BT_CLOG_OBJ_FMT_PREFIX _fmt, (_log_cfg).compName(), ##__VA_ARGS__); \
+ } else if ((_log_cfg).compCls()) { \
+ _bt_log_write_mem((_lvl), _BT_LOG_TAG, (_data), (_data_sz), \
+ _BT_CLOG_OBJ_FMT_PREFIX _fmt, (_log_cfg).compClsName(), \
+ ##__VA_ARGS__); \
+ } else { \
+ _bt_log_write_mem((_lvl), _BT_LOG_TAG, (_data), (_data_sz), _fmt, ##__VA_ARGS__); \
+ } \
+ }
+
+#define BT_CLOGF_MEM_EX(_log_cfg, _data, _data_sz, _fmt, ...) \
+ BT_CLOG_MEM_EX(BT_LOG_FATAL, (_log_cfg), (_data), (_data_sz), ##__VA_ARGS__)
+#define BT_CLOGE_MEM_EX(_log_cfg, _data, _data_sz, _fmt, ...) \
+ BT_CLOG_MEM_EX(BT_LOG_ERROR, (_log_cfg), (_data), (_data_sz), ##__VA_ARGS__)
+#define BT_CLOGW_MEM_EX(_log_cfg, _data, _data_sz, _fmt, ...) \
+ BT_CLOG_MEM_EX(BT_LOG_WARNING, (_log_cfg), (_data), (_data_sz), ##__VA_ARGS__)
+#define BT_CLOGI_MEM_EX(_log_cfg, _data, _data_sz, _fmt, ...) \
+ BT_CLOG_MEM_EX(BT_LOG_INFO, (_log_cfg), (_data), (_data_sz), ##__VA_ARGS__)
+#define BT_CLOGD_MEM_EX(_log_cfg, _data, _data_sz, _fmt, ...) \
+ BT_CLOG_MEM_EX(BT_LOG_DEBUG, (_log_cfg), (_data), (_data_sz), ##__VA_ARGS__)
+#define BT_CLOGT_MEM_EX(_log_cfg, _data, _data_sz, _fmt, ...) \
+ BT_CLOG_MEM_EX(BT_LOG_TRACE, (_log_cfg), (_data), (_data_sz), ##__VA_ARGS__)
+
+#define BT_CLOG_MEM(_lvl, _data, _data_sz, _fmt, ...) \
+ BT_CLOG_MEM_EX(_lvl, (BT_CLOG_CFG), (_data), (_data_sz), _fmt, ##__VA_ARGS__)
+#define BT_CLOGF_MEM(_data, _data_sz, _fmt, ...) \
+ BT_CLOG_MEM(BT_LOG_FATAL, (_data), (_data_sz), _fmt, ##__VA_ARGS__)
+#define BT_CLOGE_MEM(_data, _data_sz, _fmt, ...) \
+ BT_CLOG_MEM(BT_LOG_ERROR, (_data), (_data_sz), _fmt, ##__VA_ARGS__)
+#define BT_CLOGW_MEM(_data, _data_sz, _fmt, ...) \
+ BT_CLOG_MEM(BT_LOG_WARNING, (_data), (_data_sz), _fmt, ##__VA_ARGS__)
+#define BT_CLOGI_MEM(_data, _data_sz, _fmt, ...) \
+ BT_CLOG_MEM(BT_LOG_INFO, (_data), (_data_sz), _fmt, ##__VA_ARGS__)
+#define BT_CLOGD_MEM(_data, _data_sz, _fmt, ...) \
+ BT_CLOG_MEM(BT_LOG_DEBUG, (_data), (_data_sz), _fmt, ##__VA_ARGS__)
+#define BT_CLOGT_MEM(_data, _data_sz, _fmt, ...) \
+ BT_CLOG_MEM(BT_LOG_TRACE, (_data), (_data_sz), _fmt, ##__VA_ARGS__)
+
+#endif /* BABELTRACE_CPP_COMMON_CFG_LOGGING_HPP */