cpp-common/bt2c: add `BT_CPPLOGE_ERRNO_APPEND_CAUSE_SPEC`
[babeltrace.git] / src / cpp-common / bt2c / logging.hpp
index 838c555bafb4f3cfa6666542df27c7ae76ea0432..40074a27768984696dbe838cfe2a69896dd8134c 100644 (file)
@@ -924,6 +924,34 @@ private:
 #define BT_CPPLOGE_STR_APPEND_CAUSE_AND_RETHROW(_msg)                                              \
     BT_CPPLOGE_STR_APPEND_CAUSE_AND_RETHROW_SPEC(_BT_CPPLOG_DEF_LOGGER, (_msg))
 
+/*
+ * Calls logErrno() on `_logger` with the `Level::Error` level to log an
+ * error and append a cause to the error of the current thread.
+ */
+#define BT_CPPLOGE_ERRNO_APPEND_CAUSE_SPEC(_logger, _init_msg, _fmt, ...)                          \
+    (_logger).logErrno<bt2c::Logger::Level::Error, true>(__FILE__, __func__, __LINE__,             \
+                                                         (_init_msg), (_fmt), ##__VA_ARGS__)
+
+/*
+ * BT_CPPLOGE_ERRNO_APPEND_CAUSE_SPEC() using the default logger.
+ */
+#define BT_CPPLOGE_ERRNO_APPEND_CAUSE(_init_msg, _fmt, ...)                                        \
+    BT_CPPLOGE_ERRNO_APPEND_CAUSE_SPEC(_BT_CPPLOG_DEF_LOGGER, (_init_msg), (_fmt), ##__VA_ARGS__)
+
+/*
+ * Calls logErrnoStr() on `_logger` with the `Level::Error` level to log
+ * an error and append a cause to the error of the current thread.
+ */
+#define BT_CPPLOGE_ERRNO_STR_APPEND_CAUSE_SPEC(_logger, _init_msg, _msg)                           \
+    (_logger).logErrnoStr<bt2c::Logger::Level::Error, true>(__FILE__, __func__, __LINE__,          \
+                                                            (_init_msg), (_msg))
+
+/*
+ * BT_CPPLOGE_ERRNO_STR_APPEND_CAUSE_SPEC() using the default logger.
+ */
+#define BT_CPPLOGE_ERRNO_STR_APPEND_CAUSE(_init_msg, _msg)                                         \
+    BT_CPPLOGE_ERRNO_STR_APPEND_CAUSE_SPEC(_BT_CPPLOG_DEF_LOGGER, (_init_msg), (_msg))
+
 /*
  * Calls logErrorErrnoAndThrow() on `_logger` to log an error, append a
  * cause to the error of the current thread, and throw an instance of
This page took 0.024962 seconds and 4 git commands to generate.