2 * Copyright 2018 Philippe Proulx <pproulx@efficios.com>
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 #define BT_LOG_TAG "LIB/LIB-LOGGING"
24 #include "lib/logging.h"
34 #include "common/common.h"
35 #include "common/uuid.h"
36 #include <babeltrace2/babeltrace.h>
39 #include "assert-pre.h"
40 #include "assert-post.h"
42 #include "object-pool.h"
43 #include "graph/component-class.h"
44 #include "graph/component-class-sink-colander.h"
45 #include "graph/component-filter.h"
46 #include "graph/component.h"
47 #include "graph/component-sink.h"
48 #include "graph/component-source.h"
49 #include "graph/connection.h"
50 #include "graph/graph.h"
51 #include "graph/message/discarded-items.h"
52 #include "graph/message/event.h"
53 #include "graph/message/iterator.h"
54 #include "graph/message/message.h"
55 #include "graph/message/message-iterator-inactivity.h"
56 #include "graph/message/packet.h"
57 #include "graph/message/stream.h"
58 #include "graph/port.h"
59 #include "plugin/plugin.h"
60 #include "plugin/plugin-so.h"
61 #include "trace-ir/clock-class.h"
62 #include "trace-ir/clock-snapshot.h"
63 #include "trace-ir/event-class.h"
64 #include "trace-ir/event.h"
65 #include "trace-ir/field-class.h"
66 #include "trace-ir/field.h"
67 #include "trace-ir/field-path.h"
68 #include "trace-ir/packet.h"
69 #include "trace-ir/stream-class.h"
70 #include "trace-ir/stream.h"
71 #include "trace-ir/trace-class.h"
72 #include "trace-ir/trace.h"
73 #include "trace-ir/utils.h"
75 #include "assert-pre.h"
77 #define LIB_LOGGING_BUF_SIZE (4096 * 4)
79 static __thread
char lib_logging_buf
[LIB_LOGGING_BUF_SIZE
];
81 #define BUF_APPEND(_fmt, ...) \
84 size_t _size = LIB_LOGGING_BUF_SIZE - \
85 (size_t) (*buf_ch - lib_logging_buf); \
86 _count = snprintf(*buf_ch, _size, (_fmt), __VA_ARGS__); \
87 BT_ASSERT(_count >= 0); \
88 *buf_ch += MIN(_count, _size); \
89 if (*buf_ch >= lib_logging_buf + LIB_LOGGING_BUF_SIZE - 1) { \
94 #define BUF_APPEND_UUID(_uuid) \
96 BUF_APPEND(", %suuid=", prefix); \
97 format_uuid(buf_ch, (_uuid)); \
100 #define PRFIELD(_expr) prefix, (_expr)
102 #define PRFIELD_GSTRING(_expr) PRFIELD((_expr) ? (_expr)->str : NULL)
104 #define TMP_PREFIX_LEN 128
105 #define SET_TMP_PREFIX(_prefix2) \
108 snprintf(tmp_prefix, TMP_PREFIX_LEN - 1, "%s%s", \
109 prefix, (_prefix2)); \
111 if (snprintf_ret < 0 || snprintf_ret >= TMP_PREFIX_LEN - 1) { \
115 tmp_prefix[TMP_PREFIX_LEN - 1] = '\0'; \
118 static inline void format_component(char **buf_ch
, bool extended
,
119 const char *prefix
, const struct bt_component
*component
);
121 static inline void format_port(char **buf_ch
, bool extended
,
122 const char *prefix
, const struct bt_port
*port
);
124 static inline void format_connection(char **buf_ch
, bool extended
,
125 const char *prefix
, const struct bt_connection
*connection
);
127 static inline void format_clock_snapshot(char **buf_ch
, bool extended
,
128 const char *prefix
, const struct bt_clock_snapshot
*clock_snapshot
);
130 static inline void format_field_path(char **buf_ch
, bool extended
,
131 const char *prefix
, const struct bt_field_path
*field_path
);
133 static inline void format_object(char **buf_ch
, bool extended
,
134 const char *prefix
, const struct bt_object
*obj
)
136 BUF_APPEND(", %sref-count=%llu", prefix
, obj
->ref_count
);
139 static inline void format_uuid(char **buf_ch
, bt_uuid uuid
)
141 BUF_APPEND("\"" BT_UUID_FMT
"\"", BT_UUID_FMT_VALUES(uuid
));
144 static inline void format_object_pool(char **buf_ch
, bool extended
,
145 const char *prefix
, const struct bt_object_pool
*pool
)
147 BUF_APPEND(", %ssize=%zu", PRFIELD(pool
->size
));
150 BUF_APPEND(", %scap=%u", PRFIELD(pool
->objects
->len
));
154 static inline void format_integer_field_class(char **buf_ch
,
155 bool extended
, const char *prefix
,
156 const struct bt_field_class
*field_class
)
158 const struct bt_field_class_integer
*int_fc
=
159 (const void *) field_class
;
161 BUF_APPEND(", %srange-size=%" PRIu64
", %sbase=%s",
162 PRFIELD(int_fc
->range
),
163 PRFIELD(bt_common_field_class_integer_preferred_display_base_string(int_fc
->base
)));
166 static inline void format_array_field_class(char **buf_ch
,
167 bool extended
, const char *prefix
,
168 const struct bt_field_class
*field_class
)
170 const struct bt_field_class_array
*array_fc
=
171 (const void *) field_class
;
173 BUF_APPEND(", %selement-fc-addr=%p, %selement-fc-type=%s",
174 PRFIELD(array_fc
->element_fc
),
175 PRFIELD(bt_common_field_class_type_string(array_fc
->element_fc
->type
)));
178 static inline void format_field_class(char **buf_ch
, bool extended
,
179 const char *prefix
, const struct bt_field_class
*field_class
)
181 char tmp_prefix
[TMP_PREFIX_LEN
];
183 BUF_APPEND(", %stype=%s",
184 PRFIELD(bt_common_field_class_type_string(field_class
->type
)));
187 BUF_APPEND(", %sis-frozen=%d", PRFIELD(field_class
->frozen
));
188 BUF_APPEND(", %sis-part-of-trace-class=%d",
189 PRFIELD(field_class
->part_of_trace_class
));
194 switch (field_class
->type
) {
195 case BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER
:
196 case BT_FIELD_CLASS_TYPE_SIGNED_INTEGER
:
198 format_integer_field_class(buf_ch
, extended
, prefix
, field_class
);
201 case BT_FIELD_CLASS_TYPE_REAL
:
203 const struct bt_field_class_real
*real_fc
= (void *) field_class
;
205 BUF_APPEND(", %sis-single-precision=%d",
206 PRFIELD(real_fc
->is_single_precision
));
209 case BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION
:
210 case BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION
:
212 const struct bt_field_class_enumeration
*enum_fc
=
213 (const void *) field_class
;
215 format_integer_field_class(buf_ch
, extended
, prefix
, field_class
);
216 BUF_APPEND(", %smapping-count=%u",
217 PRFIELD(enum_fc
->mappings
->len
));
220 case BT_FIELD_CLASS_TYPE_STRUCTURE
:
222 const struct bt_field_class_structure
*struct_fc
=
223 (const void *) field_class
;
225 if (struct_fc
->common
.named_fcs
) {
226 BUF_APPEND(", %smember-count=%u",
227 PRFIELD(struct_fc
->common
.named_fcs
->len
));
232 case BT_FIELD_CLASS_TYPE_STATIC_ARRAY
:
234 const struct bt_field_class_static_array
*array_fc
=
235 (const void *) field_class
;
237 format_array_field_class(buf_ch
, extended
, prefix
, field_class
);
238 BUF_APPEND(", %slength=%" PRIu64
, PRFIELD(array_fc
->length
));
241 case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY
:
243 const struct bt_field_class_dynamic_array
*array_fc
=
244 (const void *) field_class
;
246 format_array_field_class(buf_ch
, extended
, prefix
, field_class
);
248 if (array_fc
->length_fc
) {
249 SET_TMP_PREFIX("length-fc-");
250 format_field_class(buf_ch
, extended
, tmp_prefix
,
251 array_fc
->length_fc
);
254 if (array_fc
->length_field_path
) {
255 SET_TMP_PREFIX("length-field-path-");
256 format_field_path(buf_ch
, extended
, tmp_prefix
,
257 array_fc
->length_field_path
);
262 case BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR
:
263 case BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_SELECTOR
:
264 case BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_SELECTOR
:
266 const struct bt_field_class_variant
*var_fc
=
267 (const void *) field_class
;
269 if (var_fc
->common
.named_fcs
) {
270 BUF_APPEND(", %soption-count=%u",
271 PRFIELD(var_fc
->common
.named_fcs
->len
));
274 if (field_class
->type
== BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_SELECTOR
||
275 field_class
->type
== BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_SELECTOR
) {
276 const struct bt_field_class_variant_with_selector
*var_with_sel_fc
=
277 (const void *) var_fc
;
279 if (var_with_sel_fc
->selector_fc
) {
280 SET_TMP_PREFIX("selector-fc-");
281 format_field_class(buf_ch
, extended
, tmp_prefix
,
282 var_with_sel_fc
->selector_fc
);
285 if (var_with_sel_fc
->selector_field_path
) {
286 SET_TMP_PREFIX("selector-field-path-");
287 format_field_path(buf_ch
, extended
, tmp_prefix
,
288 var_with_sel_fc
->selector_field_path
);
299 static inline void format_field_integer_extended(char **buf_ch
,
300 const char *prefix
, const struct bt_field
*field
)
302 const struct bt_field_integer
*integer
= (void *) field
;
303 const struct bt_field_class_integer
*field_class
=
304 (void *) field
->class;
305 const char *fmt
= NULL
;
307 BT_ASSERT(field_class
);
309 if (field_class
->base
== BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_OCTAL
) {
310 fmt
= ", %svalue=%" PRIo64
;
311 } else if (field_class
->base
== BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_HEXADECIMAL
) {
312 fmt
= ", %svalue=%" PRIx64
;
315 if (field_class
->common
.type
== BT_FIELD_CLASS_TYPE_SIGNED_INTEGER
||
316 field_class
->common
.type
== BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION
) {
318 fmt
= ", %svalue=%" PRId64
;
321 BUF_APPEND(fmt
, PRFIELD(integer
->value
.i
));
324 fmt
= ", %svalue=%" PRIu64
;
327 BUF_APPEND(fmt
, PRFIELD(integer
->value
.u
));
331 static inline void format_field(char **buf_ch
, bool extended
,
332 const char *prefix
, const struct bt_field
*field
)
334 BUF_APPEND(", %sis-set=%d", PRFIELD(field
->is_set
));
337 BUF_APPEND(", %sis-frozen=%d", PRFIELD(field
->frozen
));
340 BUF_APPEND(", %sclass-addr=%p", PRFIELD(field
->class));
346 BUF_APPEND(", %sclass-type=%s",
347 PRFIELD(bt_common_field_class_type_string(field
->class->type
)));
349 if (!extended
|| !field
->is_set
) {
353 switch (field
->class->type
) {
354 case BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER
:
355 case BT_FIELD_CLASS_TYPE_SIGNED_INTEGER
:
356 case BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION
:
357 case BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION
:
359 format_field_integer_extended(buf_ch
, prefix
, field
);
362 case BT_FIELD_CLASS_TYPE_REAL
:
364 const struct bt_field_real
*real_field
= (const void *) field
;
366 BUF_APPEND(", %svalue=%f", PRFIELD(real_field
->value
));
369 case BT_FIELD_CLASS_TYPE_STRING
:
371 const struct bt_field_string
*str
= (const void *) field
;
374 BT_ASSERT(str
->buf
->data
);
375 BUF_APPEND(", %spartial-value=\"%.32s\"",
376 PRFIELD(str
->buf
->data
));
381 case BT_FIELD_CLASS_TYPE_STATIC_ARRAY
:
382 case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY
:
384 const struct bt_field_array
*array_field
= (const void *) field
;
386 BUF_APPEND(", %slength=%" PRIu64
, PRFIELD(array_field
->length
));
388 if (array_field
->fields
) {
389 BUF_APPEND(", %sallocated-length=%u",
390 PRFIELD(array_field
->fields
->len
));
395 case BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR
:
396 case BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_SELECTOR
:
397 case BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_SELECTOR
:
399 const struct bt_field_variant
*var_field
= (const void *) field
;
401 BUF_APPEND(", %sselected-field-index=%" PRIu64
,
402 PRFIELD(var_field
->selected_index
));
410 static inline void format_field_path(char **buf_ch
, bool extended
,
411 const char *prefix
, const struct bt_field_path
*field_path
)
415 if (field_path
->items
) {
416 BT_ASSERT(field_path
->items
);
417 BUF_APPEND(", %sitem-count=%u",
418 PRFIELD(field_path
->items
->len
));
421 if (!extended
|| !field_path
->items
) {
425 BUF_APPEND(", %spath=[%s",
426 PRFIELD(bt_common_scope_string(field_path
->root
)));
428 for (i
= 0; i
< bt_field_path_get_item_count(field_path
); i
++) {
429 const struct bt_field_path_item
*fp_item
=
430 bt_field_path_borrow_item_by_index_const(field_path
, i
);
432 switch (bt_field_path_item_get_type(fp_item
)) {
433 case BT_FIELD_PATH_ITEM_TYPE_INDEX
:
434 BUF_APPEND(", %" PRIu64
,
435 bt_field_path_item_index_get_index(fp_item
));
437 case BT_FIELD_PATH_ITEM_TYPE_CURRENT_ARRAY_ELEMENT
:
438 BUF_APPEND("%s", ", <CUR>");
445 BUF_APPEND("%s", "]");
448 static inline void format_trace_class(char **buf_ch
, bool extended
,
449 const char *prefix
, const struct bt_trace_class
*trace_class
)
455 BUF_APPEND(", %sis-frozen=%d", PRFIELD(trace_class
->frozen
));
457 if (trace_class
->stream_classes
) {
458 BUF_APPEND(", %sstream-class-count=%u",
459 PRFIELD(trace_class
->stream_classes
->len
));
462 BUF_APPEND(", %sassigns-auto-sc-id=%d",
463 PRFIELD(trace_class
->assigns_automatic_stream_class_id
));
466 static inline void format_trace(char **buf_ch
, bool extended
,
467 const char *prefix
, const struct bt_trace
*trace
)
469 char tmp_prefix
[TMP_PREFIX_LEN
];
471 if (trace
->name
.value
) {
472 BUF_APPEND(", %sname=\"%s\"", PRFIELD(trace
->name
.value
));
479 if (trace
->uuid
.value
) {
480 BUF_APPEND_UUID(trace
->uuid
.value
);
483 BUF_APPEND(", %sis-frozen=%d", PRFIELD(trace
->frozen
));
485 if (trace
->streams
) {
486 BUF_APPEND(", %sstream-count=%u",
487 PRFIELD(trace
->streams
->len
));
494 BUF_APPEND(", %strace-class-addr=%p", PRFIELD(trace
->class));
495 SET_TMP_PREFIX("trace-class-");
496 format_trace_class(buf_ch
, false, tmp_prefix
, trace
->class);
499 static inline void format_stream_class(char **buf_ch
, bool extended
,
501 const struct bt_stream_class
*stream_class
)
503 const struct bt_trace_class
*trace_class
;
504 char tmp_prefix
[TMP_PREFIX_LEN
];
506 BUF_APPEND(", %sid=%" PRIu64
, PRFIELD(stream_class
->id
));
508 if (stream_class
->name
.value
) {
509 BUF_APPEND(", %sname=\"%s\"",
510 PRFIELD(stream_class
->name
.value
));
517 BUF_APPEND(", %sis-frozen=%d", PRFIELD(stream_class
->frozen
));
519 if (stream_class
->event_classes
) {
520 BUF_APPEND(", %sevent-class-count=%u",
521 PRFIELD(stream_class
->event_classes
->len
));
524 BUF_APPEND(", %spacket-context-fc-addr=%p, "
525 "%sevent-common-context-fc-addr=%p",
526 PRFIELD(stream_class
->packet_context_fc
),
527 PRFIELD(stream_class
->event_common_context_fc
));
528 trace_class
= bt_stream_class_borrow_trace_class_inline(stream_class
);
533 BUF_APPEND(", %sassigns-auto-ec-id=%d, %sassigns-auto-stream-id=%d, "
534 "%ssupports-packets=%d, "
535 "%spackets-have-begin-default-cs=%d, "
536 "%spackets-have-end-default-cs=%d, "
537 "%ssupports-discarded-events=%d, "
538 "%sdiscarded-events-have-default-cs=%d, "
539 "%ssupports-discarded-packets=%d, "
540 "%sdiscarded-packets-have-default-cs=%d",
541 PRFIELD(stream_class
->assigns_automatic_event_class_id
),
542 PRFIELD(stream_class
->assigns_automatic_stream_id
),
543 PRFIELD(stream_class
->supports_packets
),
544 PRFIELD(stream_class
->packets_have_beginning_default_clock_snapshot
),
545 PRFIELD(stream_class
->packets_have_end_default_clock_snapshot
),
546 PRFIELD(stream_class
->supports_discarded_events
),
547 PRFIELD(stream_class
->discarded_events_have_default_clock_snapshots
),
548 PRFIELD(stream_class
->supports_discarded_packets
),
549 PRFIELD(stream_class
->discarded_packets_have_default_clock_snapshots
));
550 BUF_APPEND(", %strace-class-addr=%p", PRFIELD(trace_class
));
551 SET_TMP_PREFIX("trace-class-");
552 format_trace_class(buf_ch
, false, tmp_prefix
, trace_class
);
553 SET_TMP_PREFIX("pcf-pool-");
554 format_object_pool(buf_ch
, extended
, tmp_prefix
,
555 &stream_class
->packet_context_field_pool
);
558 static inline void format_event_class(char **buf_ch
, bool extended
,
559 const char *prefix
, const struct bt_event_class
*event_class
)
561 const struct bt_stream_class
*stream_class
;
562 const struct bt_trace_class
*trace_class
;
563 char tmp_prefix
[TMP_PREFIX_LEN
];
565 BUF_APPEND(", %sid=%" PRIu64
, PRFIELD(event_class
->id
));
567 if (event_class
->name
.value
) {
568 BUF_APPEND(", %sname=\"%s\"",
569 PRFIELD(event_class
->name
.value
));
576 BUF_APPEND(", %sis-frozen=%d", PRFIELD(event_class
->frozen
));
578 if (event_class
->log_level
.base
.avail
) {
579 BUF_APPEND(", %slog-level=%s",
580 PRFIELD(bt_common_event_class_log_level_string(
581 (int) event_class
->log_level
.value
)));
584 if (event_class
->emf_uri
.value
) {
585 BUF_APPEND(", %semf-uri=\"%s\"",
586 PRFIELD(event_class
->emf_uri
.value
));
589 BUF_APPEND(", %sspecific-context-fc-addr=%p, %spayload-fc-addr=%p",
590 PRFIELD(event_class
->specific_context_fc
),
591 PRFIELD(event_class
->payload_fc
));
593 stream_class
= bt_event_class_borrow_stream_class_const(event_class
);
598 BUF_APPEND(", %sstream-class-addr=%p", PRFIELD(stream_class
));
599 SET_TMP_PREFIX("stream-class-");
600 format_stream_class(buf_ch
, false, tmp_prefix
, stream_class
);
601 trace_class
= bt_stream_class_borrow_trace_class_inline(stream_class
);
606 BUF_APPEND(", %strace-class-addr=%p", PRFIELD(trace_class
));
607 SET_TMP_PREFIX("trace-class-");
608 format_trace_class(buf_ch
, false, tmp_prefix
, trace_class
);
609 SET_TMP_PREFIX("event-pool-");
610 format_object_pool(buf_ch
, extended
, tmp_prefix
,
611 &event_class
->event_pool
);
614 static inline void format_stream(char **buf_ch
, bool extended
,
615 const char *prefix
, const struct bt_stream
*stream
)
617 const struct bt_stream_class
*stream_class
;
618 const struct bt_trace_class
*trace_class
= NULL
;
619 const struct bt_trace
*trace
= NULL
;
620 char tmp_prefix
[TMP_PREFIX_LEN
];
622 BUF_APPEND(", %sid=%" PRIu64
, PRFIELD(stream
->id
));
624 if (stream
->name
.value
) {
625 BUF_APPEND(", %sname=\"%s\"", PRFIELD(stream
->name
.value
));
632 stream_class
= bt_stream_borrow_class_const(stream
);
634 BUF_APPEND(", %sstream-class-addr=%p", PRFIELD(stream_class
));
635 SET_TMP_PREFIX("stream-class-");
636 format_stream_class(buf_ch
, false, tmp_prefix
, stream_class
);
637 trace_class
= bt_stream_class_borrow_trace_class_inline(stream_class
);
641 BUF_APPEND(", %strace-class-addr=%p", PRFIELD(trace_class
));
642 SET_TMP_PREFIX("trace-class-");
643 format_trace_class(buf_ch
, false, tmp_prefix
, trace_class
);
646 trace
= bt_stream_borrow_trace_inline(stream
);
648 BUF_APPEND(", %strace-addr=%p", PRFIELD(trace
));
649 SET_TMP_PREFIX("trace-");
650 format_trace(buf_ch
, false, tmp_prefix
, trace
);
653 SET_TMP_PREFIX("packet-pool-");
654 format_object_pool(buf_ch
, extended
, tmp_prefix
, &stream
->packet_pool
);
657 static inline void format_packet(char **buf_ch
, bool extended
,
658 const char *prefix
, const struct bt_packet
*packet
)
660 const struct bt_stream
*stream
;
661 const struct bt_trace_class
*trace_class
;
662 char tmp_prefix
[TMP_PREFIX_LEN
];
668 BUF_APPEND(", %sis-frozen=%d, %scontext-field-addr=%p",
669 PRFIELD(packet
->frozen
),
670 PRFIELD(packet
->context_field
? packet
->context_field
->field
: NULL
));
671 stream
= bt_packet_borrow_stream_const(packet
);
676 BUF_APPEND(", %sstream-addr=%p", PRFIELD(stream
));
677 SET_TMP_PREFIX("stream-");
678 format_stream(buf_ch
, false, tmp_prefix
, stream
);
679 trace_class
= (const struct bt_trace_class
*) bt_object_borrow_parent(&stream
->base
);
684 BUF_APPEND(", %strace-class-addr=%p", PRFIELD(trace_class
));
685 SET_TMP_PREFIX("trace-class-");
686 format_trace_class(buf_ch
, false, tmp_prefix
, trace_class
);
689 static inline void format_event(char **buf_ch
, bool extended
,
690 const char *prefix
, const struct bt_event
*event
)
692 const struct bt_trace_class
*trace_class
;
693 const struct bt_stream_class
*stream_class
;
694 char tmp_prefix
[TMP_PREFIX_LEN
];
700 BUF_APPEND(", %sis-frozen=%d, "
701 "%scommon-context-field-addr=%p, "
702 "%sspecific-context-field-addr=%p, "
703 "%spayload-field-addr=%p, ",
704 PRFIELD(event
->frozen
),
705 PRFIELD(event
->common_context_field
),
706 PRFIELD(event
->specific_context_field
),
707 PRFIELD(event
->payload_field
));
708 BUF_APPEND(", %sevent-class-addr=%p", PRFIELD(event
->class));
714 SET_TMP_PREFIX("event-class-");
715 format_event_class(buf_ch
, false, tmp_prefix
, event
->class);
716 stream_class
= bt_event_class_borrow_stream_class(event
->class);
718 BUF_APPEND(", %sstream-class-addr=%p", PRFIELD(stream_class
));
719 SET_TMP_PREFIX("stream-class-");
720 format_stream_class(buf_ch
, false, tmp_prefix
,
723 trace_class
= bt_stream_class_borrow_trace_class_inline(
726 BUF_APPEND(", %strace-class-addr=%p",
727 PRFIELD(trace_class
));
728 SET_TMP_PREFIX("trace-class-");
729 format_trace_class(buf_ch
, false, tmp_prefix
,
735 BUF_APPEND(", %sstream-addr=%p", PRFIELD(event
->stream
));
736 SET_TMP_PREFIX("stream-");
737 format_stream(buf_ch
, false, tmp_prefix
, event
->stream
);
741 BUF_APPEND(", %spacket-addr=%p", PRFIELD(event
->packet
));
742 SET_TMP_PREFIX("packet-");
743 format_packet(buf_ch
, false, tmp_prefix
, event
->packet
);
747 static inline void format_clock_class(char **buf_ch
, bool extended
,
748 const char *prefix
, const struct bt_clock_class
*clock_class
)
750 char tmp_prefix
[TMP_PREFIX_LEN
];
752 if (clock_class
->name
.value
) {
753 BUF_APPEND(", %sname=\"%s\"", PRFIELD(clock_class
->name
.value
));
756 BUF_APPEND(", %sfreq=%" PRIu64
, PRFIELD(clock_class
->frequency
));
762 if (clock_class
->description
.value
) {
763 BUF_APPEND(", %spartial-descr=\"%.32s\"",
764 PRFIELD(clock_class
->description
.value
));
767 if (clock_class
->uuid
.value
) {
768 BUF_APPEND_UUID(clock_class
->uuid
.value
);
771 BUF_APPEND(", %sis-frozen=%d, %sprecision=%" PRIu64
", "
772 "%soffset-s=%" PRId64
", "
773 "%soffset-cycles=%" PRIu64
", %sorigin-is-unix-epoch=%d, "
774 "%sbase-offset-ns=%" PRId64
,
775 PRFIELD(clock_class
->frozen
), PRFIELD(clock_class
->precision
),
776 PRFIELD(clock_class
->offset_seconds
),
777 PRFIELD(clock_class
->offset_cycles
),
778 PRFIELD(clock_class
->origin_is_unix_epoch
),
779 PRFIELD(clock_class
->base_offset
.value_ns
));
781 SET_TMP_PREFIX("cs-pool-");
782 format_object_pool(buf_ch
, extended
, tmp_prefix
,
783 &clock_class
->cs_pool
);
786 static inline void format_clock_snapshot(char **buf_ch
, bool extended
,
787 const char *prefix
, const struct bt_clock_snapshot
*clock_snapshot
)
789 char tmp_prefix
[TMP_PREFIX_LEN
];
790 BUF_APPEND(", %svalue=%" PRIu64
", %sns-from-origin=%" PRId64
,
791 PRFIELD(clock_snapshot
->value_cycles
),
792 PRFIELD(clock_snapshot
->ns_from_origin
));
798 BUF_APPEND(", %sis-set=%d", PRFIELD(clock_snapshot
->is_set
));
800 if (clock_snapshot
->clock_class
) {
801 BUF_APPEND(", %sclock-class-addr=%p",
802 PRFIELD(clock_snapshot
->clock_class
));
803 SET_TMP_PREFIX("clock-class-");
804 format_clock_class(buf_ch
, false, tmp_prefix
,
805 clock_snapshot
->clock_class
);
809 static inline void format_value(char **buf_ch
, bool extended
,
810 const char *prefix
, const struct bt_value
*value
)
812 BUF_APPEND(", %stype=%s",
813 PRFIELD(bt_common_value_type_string(bt_value_get_type(value
))));
819 switch (bt_value_get_type(value
)) {
820 case BT_VALUE_TYPE_BOOL
:
822 bt_bool val
= bt_value_bool_get(value
);
824 BUF_APPEND(", %svalue=%d", PRFIELD(val
));
827 case BT_VALUE_TYPE_UNSIGNED_INTEGER
:
829 BUF_APPEND(", %svalue=%" PRIu64
,
830 PRFIELD(bt_value_unsigned_integer_get(value
)));
833 case BT_VALUE_TYPE_SIGNED_INTEGER
:
835 BUF_APPEND(", %svalue=%" PRId64
,
836 PRFIELD(bt_value_signed_integer_get(value
)));
839 case BT_VALUE_TYPE_REAL
:
841 double val
= bt_value_real_get(value
);
843 BUF_APPEND(", %svalue=%f", PRFIELD(val
));
846 case BT_VALUE_TYPE_STRING
:
848 const char *val
= bt_value_string_get(value
);
850 BUF_APPEND(", %spartial-value=\"%.32s\"", PRFIELD(val
));
853 case BT_VALUE_TYPE_ARRAY
:
855 int64_t count
= bt_value_array_get_size(value
);
857 BT_ASSERT(count
>= 0);
858 BUF_APPEND(", %selement-count=%" PRId64
, PRFIELD(count
));
861 case BT_VALUE_TYPE_MAP
:
863 int64_t count
= bt_value_map_get_size(value
);
865 BT_ASSERT(count
>= 0);
866 BUF_APPEND(", %selement-count=%" PRId64
, PRFIELD(count
));
874 static inline void format_message(char **buf_ch
, bool extended
,
875 const char *prefix
, const struct bt_message
*msg
)
877 char tmp_prefix
[TMP_PREFIX_LEN
];
879 BUF_APPEND(", %stype=%s",
880 PRFIELD(bt_message_type_string(msg
->type
)));
886 BUF_APPEND(", %sis-frozen=%d, %sgraph-addr=%p",
887 PRFIELD(msg
->frozen
), PRFIELD(msg
->graph
));
890 case BT_MESSAGE_TYPE_EVENT
:
892 const struct bt_message_event
*msg_event
=
895 if (msg_event
->event
) {
896 SET_TMP_PREFIX("event-");
897 format_event(buf_ch
, true, tmp_prefix
,
901 if (msg_event
->default_cs
) {
902 SET_TMP_PREFIX("default-cs-");
903 format_clock_snapshot(buf_ch
, true, tmp_prefix
,
904 msg_event
->default_cs
);
909 case BT_MESSAGE_TYPE_STREAM_BEGINNING
:
910 case BT_MESSAGE_TYPE_STREAM_END
:
912 const struct bt_message_stream
*msg_stream
= (const void *) msg
;
914 if (msg_stream
->stream
) {
915 SET_TMP_PREFIX("stream-");
916 format_stream(buf_ch
, true, tmp_prefix
,
920 BUF_APPEND(", %sdefault-cs-state=%s",
921 PRFIELD(bt_message_stream_clock_snapshot_state_string(
922 msg_stream
->default_cs_state
)));
924 if (msg_stream
->default_cs_state
== BT_MESSAGE_STREAM_CLOCK_SNAPSHOT_STATE_KNOWN
) {
925 SET_TMP_PREFIX("default-cs-");
926 format_clock_snapshot(buf_ch
, true, tmp_prefix
,
927 msg_stream
->default_cs
);
932 case BT_MESSAGE_TYPE_PACKET_BEGINNING
:
933 case BT_MESSAGE_TYPE_PACKET_END
:
935 const struct bt_message_packet
*msg_packet
= (const void *) msg
;
937 if (msg_packet
->packet
) {
938 SET_TMP_PREFIX("packet-");
939 format_packet(buf_ch
, true, tmp_prefix
,
943 if (msg_packet
->default_cs
) {
944 SET_TMP_PREFIX("default-cs-");
945 format_clock_snapshot(buf_ch
, true, tmp_prefix
,
946 msg_packet
->default_cs
);
951 case BT_MESSAGE_TYPE_DISCARDED_EVENTS
:
952 case BT_MESSAGE_TYPE_DISCARDED_PACKETS
:
954 const struct bt_message_discarded_items
*msg_disc_items
=
957 if (msg_disc_items
->stream
) {
958 SET_TMP_PREFIX("stream-");
959 format_stream(buf_ch
, true, tmp_prefix
,
960 msg_disc_items
->stream
);
963 if (msg_disc_items
->default_begin_cs
) {
964 SET_TMP_PREFIX("begin-default-cs-");
965 format_clock_snapshot(buf_ch
, true, tmp_prefix
,
966 msg_disc_items
->default_begin_cs
);
969 if (msg_disc_items
->default_end_cs
) {
970 SET_TMP_PREFIX("end-default-cs-");
971 format_clock_snapshot(buf_ch
, true, tmp_prefix
,
972 msg_disc_items
->default_end_cs
);
975 if (msg_disc_items
->count
.base
.avail
) {
976 BUF_APPEND(", %scount=%" PRIu64
,
977 PRFIELD(msg_disc_items
->count
.value
));
987 static inline void format_plugin_so_shared_lib_handle(char **buf_ch
,
989 const struct bt_plugin_so_shared_lib_handle
*handle
)
991 BUF_APPEND(", %saddr=%p", PRFIELD(handle
));
994 BUF_APPEND(", %spath=\"%s\"", PRFIELD_GSTRING(handle
->path
));
998 static inline void format_component_class(char **buf_ch
, bool extended
,
1000 const struct bt_component_class
*comp_class
)
1002 char tmp_prefix
[TMP_PREFIX_LEN
];
1004 BUF_APPEND(", %stype=%s, %sname=\"%s\"",
1005 PRFIELD(bt_component_class_type_string(comp_class
->type
)),
1006 PRFIELD_GSTRING(comp_class
->name
));
1008 if (comp_class
->description
) {
1009 BUF_APPEND(", %spartial-descr=\"%.32s\"",
1010 PRFIELD_GSTRING(comp_class
->description
));
1017 BUF_APPEND(", %sis-frozen=%d", PRFIELD(comp_class
->frozen
));
1019 if (comp_class
->so_handle
) {
1020 SET_TMP_PREFIX("so-handle-");
1021 format_plugin_so_shared_lib_handle(buf_ch
, tmp_prefix
,
1022 comp_class
->so_handle
);
1026 static inline void format_component(char **buf_ch
, bool extended
,
1027 const char *prefix
, const struct bt_component
*component
)
1029 char tmp_prefix
[TMP_PREFIX_LEN
];
1031 BUF_APPEND(", %sname=\"%s\", %slog-level=%s",
1032 PRFIELD_GSTRING(component
->name
),
1033 PRFIELD(bt_common_logging_level_string(component
->log_level
)));
1035 if (component
->class) {
1036 SET_TMP_PREFIX("class-");
1037 format_component_class(buf_ch
, extended
, tmp_prefix
,
1045 if (component
->input_ports
) {
1046 BUF_APPEND(", %sinput-port-count=%u",
1047 PRFIELD(component
->input_ports
->len
));
1050 if (component
->output_ports
) {
1051 BUF_APPEND(", %soutput-port-count=%u",
1052 PRFIELD(component
->output_ports
->len
));
1056 static inline void format_port(char **buf_ch
, bool extended
,
1057 const char *prefix
, const struct bt_port
*port
)
1059 char tmp_prefix
[TMP_PREFIX_LEN
];
1061 BUF_APPEND(", %stype=%s, %sname=\"%s\"",
1062 PRFIELD(bt_port_type_string(port
->type
)),
1063 PRFIELD_GSTRING(port
->name
));
1069 if (port
->connection
) {
1070 SET_TMP_PREFIX("conn-");
1071 format_connection(buf_ch
, false, tmp_prefix
, port
->connection
);
1075 static inline void format_connection(char **buf_ch
, bool extended
,
1076 const char *prefix
, const struct bt_connection
*connection
)
1078 char tmp_prefix
[TMP_PREFIX_LEN
];
1084 if (connection
->upstream_port
) {
1085 SET_TMP_PREFIX("upstream-port-");
1086 format_port(buf_ch
, false, tmp_prefix
,
1087 connection
->upstream_port
);
1090 if (connection
->downstream_port
) {
1091 SET_TMP_PREFIX("downstream-port-");
1092 format_port(buf_ch
, false, tmp_prefix
,
1093 connection
->downstream_port
);
1097 static inline void format_graph(char **buf_ch
, bool extended
,
1098 const char *prefix
, const struct bt_graph
*graph
)
1100 char tmp_prefix
[TMP_PREFIX_LEN
];
1102 BUF_APPEND(", %sis-canceled=%d, %scan-consume=%d, "
1103 "%sconfig-state=%s",
1104 PRFIELD(graph
->canceled
),
1105 PRFIELD(graph
->can_consume
),
1106 PRFIELD(bt_graph_configuration_state_string(graph
->config_state
)));
1112 if (graph
->components
) {
1113 BUF_APPEND(", %scomp-count=%u",
1114 PRFIELD(graph
->components
->len
));
1117 if (graph
->connections
) {
1118 BUF_APPEND(", %sconn-count=%u",
1119 PRFIELD(graph
->connections
->len
));
1122 SET_TMP_PREFIX("en-pool-");
1123 format_object_pool(buf_ch
, extended
, tmp_prefix
,
1124 &graph
->event_msg_pool
);
1125 SET_TMP_PREFIX("pbn-pool-");
1126 format_object_pool(buf_ch
, extended
, tmp_prefix
,
1127 &graph
->packet_begin_msg_pool
);
1128 SET_TMP_PREFIX("pen-pool-");
1129 format_object_pool(buf_ch
, extended
, tmp_prefix
,
1130 &graph
->packet_end_msg_pool
);
1133 static inline void format_message_iterator(char **buf_ch
,
1134 bool extended
, const char *prefix
,
1135 const struct bt_message_iterator
*iterator
)
1138 char tmp_prefix
[TMP_PREFIX_LEN
];
1140 if (iterator
->type
== BT_MESSAGE_ITERATOR_TYPE_SELF_COMPONENT_PORT_INPUT
) {
1141 type
= "BT_MESSAGE_ITERATOR_TYPE_SELF_COMPONENT_PORT_INPUT";
1142 } else if (iterator
->type
== BT_MESSAGE_ITERATOR_TYPE_PORT_OUTPUT
) {
1143 type
= "BT_MESSAGE_ITERATOR_TYPE_PORT_OUTPUT";
1148 BUF_APPEND(", %stype=%s", PRFIELD(type
));
1150 switch (iterator
->type
) {
1151 case BT_MESSAGE_ITERATOR_TYPE_SELF_COMPONENT_PORT_INPUT
:
1153 const struct bt_self_component_port_input_message_iterator
*
1154 port_in_iter
= (const void *) iterator
;
1156 if (port_in_iter
->upstream_component
) {
1157 SET_TMP_PREFIX("upstream-comp-");
1158 format_component(buf_ch
, false, tmp_prefix
,
1159 port_in_iter
->upstream_component
);
1162 if (port_in_iter
->upstream_port
) {
1163 SET_TMP_PREFIX("upstream-port-");
1164 format_port(buf_ch
, false, tmp_prefix
,
1165 port_in_iter
->upstream_port
);
1168 if (port_in_iter
->connection
) {
1169 SET_TMP_PREFIX("upstream-conn-");
1170 format_connection(buf_ch
, false, tmp_prefix
,
1171 port_in_iter
->connection
);
1175 case BT_MESSAGE_ITERATOR_TYPE_PORT_OUTPUT
:
1177 const struct bt_port_output_message_iterator
*port_out_iter
=
1178 (const void *) iterator
;
1180 if (port_out_iter
->graph
) {
1181 SET_TMP_PREFIX("graph-");
1182 format_graph(buf_ch
, false, tmp_prefix
,
1183 port_out_iter
->graph
);
1186 if (port_out_iter
->colander
) {
1187 SET_TMP_PREFIX("colander-comp-");
1188 format_component(buf_ch
, false, tmp_prefix
,
1189 (void *) port_out_iter
->colander
);
1199 static inline void format_plugin(char **buf_ch
, bool extended
,
1200 const char *prefix
, const struct bt_plugin
*plugin
)
1202 char tmp_prefix
[TMP_PREFIX_LEN
];
1204 BUF_APPEND(", %stype=%s", PRFIELD(bt_plugin_type_string(plugin
->type
)));
1206 if (plugin
->info
.path_set
) {
1207 BUF_APPEND(", %spath=\"%s\"",
1208 PRFIELD_GSTRING(plugin
->info
.path
));
1211 if (plugin
->info
.name_set
) {
1212 BUF_APPEND(", %sname=\"%s\"",
1213 PRFIELD_GSTRING(plugin
->info
.name
));
1220 if (plugin
->info
.author_set
) {
1221 BUF_APPEND(", %sauthor=\"%s\"",
1222 PRFIELD_GSTRING(plugin
->info
.author
));
1225 if (plugin
->info
.license_set
) {
1226 BUF_APPEND(", %slicense=\"%s\"",
1227 PRFIELD_GSTRING(plugin
->info
.license
));
1230 if (plugin
->info
.version_set
) {
1231 BUF_APPEND(", %sversion=%u.%u.%u%s",
1232 PRFIELD(plugin
->info
.version
.major
),
1233 plugin
->info
.version
.minor
,
1234 plugin
->info
.version
.patch
,
1235 plugin
->info
.version
.extra
?
1236 plugin
->info
.version
.extra
->str
: "");
1239 BUF_APPEND(", %ssrc-comp-class-count=%u, %sflt-comp-class-count=%u, "
1240 "%ssink-comp-class-count=%u",
1241 PRFIELD(plugin
->src_comp_classes
->len
),
1242 PRFIELD(plugin
->flt_comp_classes
->len
),
1243 PRFIELD(plugin
->sink_comp_classes
->len
));
1245 if (plugin
->spec_data
) {
1246 const struct bt_plugin_so_spec_data
*spec_data
=
1247 (const void *) plugin
->spec_data
;
1249 if (spec_data
->shared_lib_handle
) {
1250 SET_TMP_PREFIX("so-handle-");
1251 format_plugin_so_shared_lib_handle(buf_ch
, tmp_prefix
,
1252 spec_data
->shared_lib_handle
);
1257 static inline void format_error_cause(char **buf_ch
, bool extended
,
1258 const char *prefix
, const struct bt_error_cause
*cause
)
1260 const struct bt_error_cause_component_class_id
*comp_class_id
= NULL
;
1262 BUF_APPEND(", %sactor-type=%s, %smodule-name=\"%s\"",
1263 PRFIELD(bt_error_cause_actor_type_string(cause
->actor_type
)),
1264 PRFIELD_GSTRING(cause
->module_name
));
1270 BUF_APPEND(", %spartial-msg=\"%.32s\"",
1271 PRFIELD_GSTRING(cause
->message
));
1273 switch (cause
->actor_type
) {
1274 case BT_ERROR_CAUSE_ACTOR_TYPE_COMPONENT
:
1276 const struct bt_error_cause_component_actor
*spec_cause
=
1277 (const void *) cause
;
1279 BUF_APPEND(", %scomp-name=\"%s\"",
1280 PRFIELD_GSTRING(spec_cause
->comp_name
));
1281 comp_class_id
= &spec_cause
->comp_class_id
;
1284 case BT_ERROR_CAUSE_ACTOR_TYPE_COMPONENT_CLASS
:
1286 const struct bt_error_cause_component_class_actor
*spec_cause
=
1287 (const void *) cause
;
1289 comp_class_id
= &spec_cause
->comp_class_id
;
1292 case BT_ERROR_CAUSE_ACTOR_TYPE_MESSAGE_ITERATOR
:
1294 const struct bt_error_cause_message_iterator_actor
*spec_cause
=
1295 (const void *) cause
;
1297 BUF_APPEND(", %scomp-name=\"%s\", %scomp-out-port-name=\"%s\"",
1298 PRFIELD_GSTRING(spec_cause
->comp_name
),
1299 PRFIELD_GSTRING(spec_cause
->output_port_name
));
1300 comp_class_id
= &spec_cause
->comp_class_id
;
1307 if (comp_class_id
) {
1308 BUF_APPEND(", %scomp-cls-type=%s, %scomp-cls-name=\"%s\", "
1309 "%splugin-name=\"%s\"",
1310 PRFIELD(bt_component_class_type_string(
1311 comp_class_id
->type
)),
1312 PRFIELD_GSTRING(comp_class_id
->name
),
1313 PRFIELD_GSTRING(comp_class_id
->plugin_name
));
1317 static inline void handle_conversion_specifier_bt(void *priv_data
,
1318 char **buf_ch
, size_t avail_size
,
1319 const char **out_fmt_ch
, va_list *args
)
1321 const char *fmt_ch
= *out_fmt_ch
;
1322 bool extended
= false;
1324 char *prefix_ch
= prefix
;
1330 if (*fmt_ch
== 'u') {
1332 obj
= va_arg(*args
, void *);
1333 format_uuid(buf_ch
, obj
);
1337 if (*fmt_ch
== '[') {
1342 if (*fmt_ch
== ']') {
1348 *prefix_ch
= *fmt_ch
;
1356 if (*fmt_ch
== '+') {
1361 obj
= va_arg(*args
, void *);
1362 BUF_APPEND("%saddr=%p", prefix
, obj
);
1370 format_field_class(buf_ch
, extended
, prefix
, obj
);
1373 format_field(buf_ch
, extended
, prefix
, obj
);
1376 format_field_path(buf_ch
, extended
, prefix
, obj
);
1379 format_event_class(buf_ch
, extended
, prefix
, obj
);
1382 format_event(buf_ch
, extended
, prefix
, obj
);
1385 format_stream_class(buf_ch
, extended
, prefix
, obj
);
1388 format_stream(buf_ch
, extended
, prefix
, obj
);
1391 format_packet(buf_ch
, extended
, prefix
, obj
);
1394 format_trace(buf_ch
, extended
, prefix
, obj
);
1397 format_trace_class(buf_ch
, extended
, prefix
, obj
);
1400 format_clock_class(buf_ch
, extended
, prefix
, obj
);
1403 format_clock_snapshot(buf_ch
, extended
, prefix
, obj
);
1406 format_value(buf_ch
, extended
, prefix
, obj
);
1409 format_message(buf_ch
, extended
, prefix
, obj
);
1412 format_message_iterator(buf_ch
, extended
, prefix
, obj
);
1415 format_component_class(buf_ch
, extended
, prefix
, obj
);
1418 format_component(buf_ch
, extended
, prefix
, obj
);
1421 format_port(buf_ch
, extended
, prefix
, obj
);
1424 format_connection(buf_ch
, extended
, prefix
, obj
);
1427 format_plugin(buf_ch
, extended
, prefix
, obj
);
1430 format_graph(buf_ch
, extended
, prefix
, obj
);
1433 format_object_pool(buf_ch
, extended
, prefix
, obj
);
1436 format_object(buf_ch
, extended
, prefix
, obj
);
1439 format_error_cause(buf_ch
, extended
, prefix
, obj
);
1447 *out_fmt_ch
= fmt_ch
;
1450 void bt_lib_log(const char *func
, const char *file
, unsigned line
,
1451 int lvl
, const char *tag
, const char *fmt
, ...)
1456 va_start(args
, fmt
);
1457 bt_common_custom_vsnprintf(lib_logging_buf
, LIB_LOGGING_BUF_SIZE
, '!',
1458 handle_conversion_specifier_bt
, NULL
, fmt
, &args
);
1460 _bt_log_write_d(func
, file
, line
, lvl
, tag
, "%s", lib_logging_buf
);
1463 void bt_lib_maybe_log_and_append_cause(const char *func
, const char *file
,
1464 unsigned line
, int lvl
, const char *tag
,
1465 const char *fmt
, ...)
1468 bt_current_thread_error_append_cause_status status
;
1471 va_start(args
, fmt
);
1472 bt_common_custom_vsnprintf(lib_logging_buf
, LIB_LOGGING_BUF_SIZE
, '!',
1473 handle_conversion_specifier_bt
, NULL
, fmt
, &args
);
1476 /* Log conditionally, but always append the error cause */
1477 if (BT_LOG_ON(lvl
)) {
1478 _bt_log_write_d(func
, file
, line
, lvl
, tag
, "%s",
1482 status
= bt_current_thread_error_append_cause_from_unknown(
1483 "Babeltrace library", file
, line
, "%s", lib_logging_buf
);
1486 * Worst case: this error cause is not appended to the
1487 * current thread's error.
1489 * We can accept this as it's an almost impossible
1490 * scenario and returning an error here would mean you
1491 * need to check the return value of each
1492 * BT_LIB_LOG*_APPEND_CAUSE() macro and that would be
1495 BT_LOGE("Cannot append error cause to current thread's "
1496 "error object: status=%s",
1497 bt_common_func_status_string(status
));