lib: add _msg parameters to _ERRNO logging macros
[babeltrace.git] / src / logging / comp-logging.h
index aae775c579266e55d1d02013abe5b7da81436bde..1edabc0052947fa93bb7887bef3b169d00a821aa 100644 (file)
 #define BT_COMP_LOGE_APPEND_CAUSE(_self_comp, _fmt, ...)                       \
        BT_COMP_LOG_APPEND_CAUSE(_self_comp, BT_LOG_ERROR, _fmt, ##__VA_ARGS__)
 
+/*
+ * Logs and appends error cause from component context - the errno edition.
+ */
+#define BT_COMP_LOG_APPEND_CAUSE_ERRNO(_self_comp, _lvl, _msg, _fmt, ...)              \
+       do {                                                                            \
+               const char *error_str = g_strerror(errno);                              \
+               BT_COMP_LOG(_lvl, _self_comp, _msg ": %s" _fmt, error_str,              \
+                       ##__VA_ARGS__);                                                 \
+               (void) BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_COMPONENT(             \
+                       _self_comp, _msg ": %s" _fmt, error_str, ##__VA_ARGS__);        \
+       } while (0)
+
+/*
+ * Logs error and appends error cause from component context - the errno
+ * edition.
+ */
+#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 and appends error cause from component class context. */
 #define BT_COMP_CLASS_LOG_APPEND_CAUSE(_self_comp_class, _lvl, _fmt, ...)              \
        do {                                                                            \
  * Logs error and appends error cause from component class context - the errno
  * edition.
  */
-#define BT_COMP_CLASS_LOGE_APPEND_CAUSE_ERRNO(_self_comp_class, _fmt, ...)             \
-       BT_COMP_CLASS_LOG_APPEND_CAUSE_ERRNO(_self_comp_class, BT_LOG_ERROR, _fmt,      \
+#define BT_COMP_CLASS_LOGE_APPEND_CAUSE_ERRNO(_self_comp_class, _msg, _fmt, ...)               \
+       BT_COMP_CLASS_LOG_APPEND_CAUSE_ERRNO(_self_comp_class, BT_LOG_ERROR, _msg, _fmt,        \
                ##__VA_ARGS__)
 
 /*
This page took 0.025362 seconds and 4 git commands to generate.