#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, _fmt, ...) \
+ BT_COMP_LOG_APPEND_CAUSE_ERRNO(_self_comp, BT_LOG_ERROR, _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 { \
* SOFTWARE.
*/
-#define BT_COMP_LOG_SELF_COMP (trimmer_comp->self_comp)
#define BT_LOG_OUTPUT_LEVEL (trimmer_comp->log_level)
#define BT_LOG_TAG "PLUGIN/FLT.UTILS.TRIMMER"
#include "logging/comp-logging.h"
goto end;
}
- BT_COMP_LOGE("Invalid date/time format: param=\"%s\"", str);
+ BT_COMP_LOGE_APPEND_CAUSE(trimmer_comp->self_comp,
+ "Invalid date/time format: param=\"%s\"", str);
ret = -1;
end:
} else if (bt_value_is_string(param)) {
arg = bt_value_string_get(param);
} else {
- BT_COMP_LOGE("`%s` parameter must be an integer or a string value.",
+ BT_COMP_LOGE_APPEND_CAUSE(trimmer_comp->self_comp,
+ "`%s` parameter must be an integer or a string value.",
param_name);
ret = -1;
goto end;
if (!begin->is_infinite && !end->is_infinite &&
begin->ns_from_origin > end->ns_from_origin) {
- BT_COMP_LOGE("Trimming time range's beginning time is greater than end time: "
+ BT_COMP_LOGE_APPEND_CAUSE(trimmer_comp->self_comp,
+ "Trimming time range's beginning time is greater than end time: "
"begin-ns-from-origin=%" PRId64 ", "
"end-ns-from-origin=%" PRId64,
begin->ns_from_origin,
}
if (!begin->is_infinite && begin->ns_from_origin == INT64_MIN) {
- BT_COMP_LOGE("Invalid trimming time range's beginning time: "
+ BT_COMP_LOGE_APPEND_CAUSE(trimmer_comp->self_comp,
+ "Invalid trimming time range's beginning time: "
"ns-from-origin=%" PRId64,
begin->ns_from_origin);
ret = -1;
}
if (!end->is_infinite && end->ns_from_origin == INT64_MIN) {
- BT_COMP_LOGE("Invalid trimming time range's end time: "
+ BT_COMP_LOGE_APPEND_CAUSE(trimmer_comp->self_comp,
+ "Invalid trimming time range's end time: "
"ns-from-origin=%" PRId64,
end->ns_from_origin);
ret = -1;
}
if (!res) {
- BT_COMP_LOGE_ERRNO("Cannot convert timestamp to date and time",
+ BT_COMP_LOGE_APPEND_CAUSE_ERRNO(trimmer_comp->self_comp,
+ "Cannot convert timestamp to date and time",
": ts=%" PRId64, (int64_t) time_seconds);
ret = -1;
goto end;
if (trimmer_it->begin.is_infinite) {
if (!bt_self_component_port_input_message_iterator_can_seek_beginning(
trimmer_it->upstream_iter)) {
- BT_COMP_LOGE_STR("Cannot make upstream message iterator initially seek its beginning.");
+ BT_COMP_LOGE_APPEND_CAUSE(trimmer_comp->self_comp,
+ "Cannot make upstream message iterator initially seek its beginning.");
status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR;
goto end;
}
if (!bt_self_component_port_input_message_iterator_can_seek_ns_from_origin(
trimmer_it->upstream_iter,
trimmer_it->begin.ns_from_origin)) {
- BT_COMP_LOGE("Cannot make upstream message iterator initially seek: "
- "seek-ns-from-origin=%" PRId64,
+ BT_COMP_LOGE_APPEND_CAUSE(trimmer_comp->self_comp,
+ "Cannot make upstream message iterator initially seek: seek-ns-from-origin=%" PRId64,
trimmer_it->begin.ns_from_origin);
status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR;
goto end;
*/
sc = bt_stream_borrow_class_const(stream);
if (!bt_stream_class_borrow_default_clock_class_const(sc)) {
- BT_COMP_LOGE("Unsupported stream: stream class does "
+ BT_COMP_LOGE_APPEND_CAUSE(trimmer_comp->self_comp,
+ "Unsupported stream: stream class does "
"not have a default clock class: "
"stream-addr=%p, "
"stream-id=%" PRIu64 ", "
*/
if (!bt_stream_class_packets_have_beginning_default_clock_snapshot(
sc)) {
- BT_COMP_LOGE("Unsupported stream: packets have "
- "no beginning clock snapshot: "
+ BT_COMP_LOGE_APPEND_CAUSE(trimmer_comp->self_comp,
+ "Unsupported stream: packets have no beginning clock snapshot: "
"stream-addr=%p, "
"stream-id=%" PRIu64 ", "
"stream-name=\"%s\"",
if (!bt_stream_class_packets_have_end_default_clock_snapshot(
sc)) {
- BT_COMP_LOGE("Unsupported stream: packets have "
- "no end clock snapshot: "
+ BT_COMP_LOGE_APPEND_CAUSE(trimmer_comp->self_comp,
+ "Unsupported stream: packets have no end clock snapshot: "
"stream-addr=%p, "
"stream-id=%" PRIu64 ", "
"stream-name=\"%s\"",
if (bt_stream_class_supports_discarded_events(sc) &&
!bt_stream_class_discarded_events_have_default_clock_snapshots(sc)) {
- BT_COMP_LOGE("Unsupported stream: discarded events "
- "have no clock snapshots: "
+ BT_COMP_LOGE_APPEND_CAUSE(trimmer_comp->self_comp,
+ "Unsupported stream: discarded events have no clock snapshots: "
"stream-addr=%p, "
"stream-id=%" PRIu64 ", "
"stream-name=\"%s\"",
if (bt_stream_class_supports_discarded_packets(sc) &&
!bt_stream_class_discarded_packets_have_default_clock_snapshots(sc)) {
- BT_COMP_LOGE("Unsupported stream: discarded packets "
+ BT_COMP_LOGE_APPEND_CAUSE(trimmer_comp->self_comp,
+ "Unsupported stream: discarded packets "
"have no clock snapshots: "
"stream-addr=%p, "
"stream-id=%" PRIu64 ", "