src.ctf.lttng-live: use `_APPEND_CAUSE` variants of logging macros
[babeltrace.git] / src / logging / comp-logging.h
index 1edabc0052947fa93bb7887bef3b169d00a821aa..8d429ed1650d911177f1771b5e490dc933d92650 100644 (file)
 #define BT_COMP_LOGE_APPEND_CAUSE_ERRNO(_self_comp, _msg, _fmt, ...)                           \
        BT_COMP_LOG_APPEND_CAUSE_ERRNO(_self_comp, BT_LOG_ERROR, _msg, _fmt, ##__VA_ARGS__)
 
+/* Logs error from component class context. */
+#define BT_COMP_CLASS_LOGE(_self_comp_class, _fmt, ...)                                        \
+       BT_COMP_CLASS_LOG(BT_LOG_ERROR,_self_comp_class, _fmt, ##__VA_ARGS__)
+
 /* Logs and appends error cause from component class context. */
 #define BT_COMP_CLASS_LOG_APPEND_CAUSE(_self_comp_class, _lvl, _fmt, ...)              \
        do {                                                                            \
        BT_COMP_CLASS_LOG_APPEND_CAUSE_ERRNO(_self_comp_class, BT_LOG_ERROR, _msg, _fmt,        \
                ##__VA_ARGS__)
 
+/*
+ * Logs error from component or component class context, depending on whichever
+ * is set.
+ */
+#define BT_COMP_OR_COMP_CLASS_LOGE(_self_comp, _self_comp_class, _fmt, ...)                    \
+       do {                                                                                    \
+               /* Only one of `_self_comp` and `_self_comp_class` must be set. */              \
+               BT_ASSERT((!!(_self_comp) != (!!_self_comp_class)));                            \
+               if (_self_comp) {                                                               \
+                       BT_COMP_LOGE(_fmt, ##__VA_ARGS__);                                      \
+               } else {                                                                        \
+                       BT_COMP_CLASS_LOGE(_self_comp_class, _fmt, ##__VA_ARGS__);              \
+               }                                                                               \
+       } while (0)
+
 /*
  * Logs error and appends error cause from component or component class context,
  * depending on whichever is set.
This page took 0.023201 seconds and 4 git commands to generate.