cpp-common: remove `cfg-*.hpp` and `log-cfg.hpp`
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Tue, 14 Nov 2023 20:27:01 +0000 (15:27 -0500)
committerSimon Marchi <simon.marchi@efficios.com>
Thu, 14 Dec 2023 15:57:04 +0000 (10:57 -0500)
Those are not used currently and I plan to replace them with something
more woke for C++.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ied48a1f6a5c32426a8d85e32c6a5682c48dd4e42
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11389
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
CI-Build: Simon Marchi <simon.marchi@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
src/Makefile.am
src/cpp-common/cfg-error-reporting-throw.hpp [deleted file]
src/cpp-common/cfg-error-reporting.hpp [deleted file]
src/cpp-common/cfg-logging-error-reporting-throw.hpp [deleted file]
src/cpp-common/cfg-logging-error-reporting.hpp [deleted file]
src/cpp-common/cfg-logging.hpp [deleted file]
src/cpp-common/log-cfg.hpp [deleted file]

index a2c5d8a8d4c4d8fa00633dca082127c6d945ef61..02b5a173b6adce97f949c5a1b110e6939fb4109e 100644 (file)
@@ -41,17 +41,11 @@ noinst_HEADERS = \
        cpp-common/bt2/value.hpp \
        cpp-common/bt2/wrap.hpp \
        cpp-common/align.hpp \
-       cpp-common/cfg-error-reporting.hpp \
-       cpp-common/cfg-error-reporting-throw.hpp \
-       cpp-common/cfg-logging-error-reporting.hpp \
-       cpp-common/cfg-logging-error-reporting-throw.hpp \
-       cpp-common/cfg-logging.hpp \
        cpp-common/endian.hpp \
        cpp-common/exc.hpp \
        cpp-common/glib-up.hpp \
        cpp-common/libc-up.hpp \
        cpp-common/lib-str.hpp \
-       cpp-common/log-cfg.hpp \
        cpp-common/make-unique.hpp \
        cpp-common/nlohmann/json.hpp \
        cpp-common/optional.hpp \
diff --git a/src/cpp-common/cfg-error-reporting-throw.hpp b/src/cpp-common/cfg-error-reporting-throw.hpp
deleted file mode 100644 (file)
index 6d39877..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * 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 */
diff --git a/src/cpp-common/cfg-error-reporting.hpp b/src/cpp-common/cfg-error-reporting.hpp
deleted file mode 100644 (file)
index 49a2081..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * 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>
-
-/*
- * 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 */
diff --git a/src/cpp-common/cfg-logging-error-reporting-throw.hpp b/src/cpp-common/cfg-logging-error-reporting-throw.hpp
deleted file mode 100644 (file)
index 16de0ce..0000000
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * 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 */
diff --git a/src/cpp-common/cfg-logging-error-reporting.hpp b/src/cpp-common/cfg-logging-error-reporting.hpp
deleted file mode 100644 (file)
index 1cdc079..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * 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-error-reporting.hpp"
-#include "cfg-logging.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 */
diff --git a/src/cpp-common/cfg-logging.hpp b/src/cpp-common/cfg-logging.hpp
deleted file mode 100644 (file)
index cdd1308..0000000
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * 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 */
diff --git a/src/cpp-common/log-cfg.hpp b/src/cpp-common/log-cfg.hpp
deleted file mode 100644 (file)
index 5671b65..0000000
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * SPDX-License-Identifier: MIT
- *
- * Copyright (c) 2022 Francis Deslauriers <francis.deslauriers@efficios.com>
- * Copyright (c) 2022 Philippe Proulx <pproulx@efficios.com>
- */
-
-#ifndef BABELTRACE_CPP_COMMON_LOG_CFG_HPP
-#define BABELTRACE_CPP_COMMON_LOG_CFG_HPP
-
-#include <babeltrace2/babeltrace.h>
-
-#include "common/assert.h"
-
-namespace bt2_common {
-
-/*
- * Logging configuration.
- *
- * A logging configuration object contains all the execution context
- * needed to:
- *
- * • Log, providing the name of some current component or component
- *   class.
- *
- * • Append a cause to the error of the current thread from the right
- *   actor.
- *
- * For a given logging configuration `L`, the guarantees are as such:
- *
- * If `L.selfMsgIter()` isn't `nullptr`:
- *     • `L.selfComp()` isn't `nullptr`.
- *     • `L.compCls()` isn't `nullptr`.
- *     • `L.compName()` isn't `nullptr`.
- *     • `L.compClsName()` isn't `nullptr`.
- *     • `L.moduleName()` is `nullptr`.
- *
- * If `L.selfComp()` isn't `nullptr`:
- *     • `L.compCls()` isn't `nullptr`.
- *     • `L.compName()` isn't `nullptr`.
- *     • `L.compClsName()` isn't `nullptr`.
- *     • `L.moduleName()` is `nullptr`.
- *
- * If `L.selfCompCls()` isn't `nullptr`:
- *     • `L.compCls()` isn't `nullptr`.
- *     • `L.compClsName()` isn't `nullptr`.
- *     • `L.moduleName()` is `nullptr`.
- *
- * If `L.compCls()` isn't `nullptr`:
- *     • `L.compClsName()` isn't `nullptr`.
- *     • `L.moduleName()` is `nullptr`.
- *
- * If `L.moduleName()` isn't `nullptr`:
- *     • `L.selfMsgIter()` is `nullptr`.
- *     • `L.selfComp()` is `nullptr`.
- *     • `L.compCls()` is `nullptr`.
- *     • `L.compName()` is `nullptr`.
- *     • `L.compClsName()` is `nullptr`.
- */
-class LogCfg final
-{
-public:
-    explicit LogCfg(const bt_logging_level logLevel, bt_self_message_iterator& selfMsgIter) :
-        _mLogLevel {logLevel}, _mSelfMsgIter {&selfMsgIter},
-        _mSelfComp {bt_self_message_iterator_borrow_component(&selfMsgIter)},
-        _mCompCls {&this->_compClsFromSelfComp(*_mSelfComp)}
-    {
-    }
-
-    explicit LogCfg(const bt_logging_level logLevel, bt_self_component& selfComp) :
-        _mLogLevel {logLevel}, _mSelfComp {&selfComp}, _mCompCls {
-                                                           &this->_compClsFromSelfComp(*_mSelfComp)}
-    {
-    }
-
-    explicit LogCfg(const bt_logging_level logLevel, bt_self_component_class& selfCompCls) :
-        _mLogLevel {logLevel}, _mSelfCompCls {&selfCompCls},
-        _mCompCls {bt_self_component_class_as_component_class(&selfCompCls)}
-    {
-    }
-
-    explicit LogCfg(const bt_logging_level logLevel, const char * const moduleName) :
-        _mLogLevel {logLevel}, _mModuleName {moduleName}
-    {
-        BT_ASSERT_DBG(_mModuleName);
-    }
-
-    LogCfg(const LogCfg&) = default;
-    LogCfg& operator=(const LogCfg&) = default;
-
-    bt_logging_level logLevel() const noexcept
-    {
-        return _mLogLevel;
-    }
-
-    bt_self_component *selfComp() const noexcept
-    {
-        return _mSelfComp;
-    }
-
-    const char *compName() const noexcept
-    {
-        BT_ASSERT_DBG(_mSelfComp);
-        return bt_component_get_name(bt_self_component_as_component(_mSelfComp));
-    }
-
-    bt_self_component_class *selfCompCls() const noexcept
-    {
-        return _mSelfCompCls;
-    }
-
-    const bt_component_class *compCls() const noexcept
-    {
-        return _mCompCls;
-    }
-
-    const char *compClsName() const noexcept
-    {
-        BT_ASSERT_DBG(_mCompCls);
-        return bt_component_class_get_name(_mCompCls);
-    }
-
-    bt_self_message_iterator *selfMsgIter() const noexcept
-    {
-        return _mSelfMsgIter;
-    }
-
-    const char *moduleName() const noexcept
-    {
-        return _mModuleName;
-    }
-
-private:
-    static const bt_component_class& _compClsFromSelfComp(bt_self_component& selfComp) noexcept
-    {
-        return *bt_component_borrow_class_const(bt_self_component_as_component(&selfComp));
-    }
-
-    bt_logging_level _mLogLevel;
-    bt_self_message_iterator *_mSelfMsgIter = nullptr;
-    bt_self_component *_mSelfComp = nullptr;
-    bt_self_component_class *_mSelfCompCls = nullptr;
-    const bt_component_class *_mCompCls = nullptr;
-    const char *_mModuleName = nullptr;
-};
-
-} /* namespace bt2_common */
-
-#endif /* BABELTRACE_CPP_COMMON_LOG_CFG_HPP */
This page took 0.031985 seconds and 4 git commands to generate.