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
24 * This is just to satisfy the preprocessor check in "lib/logging.h":
25 * this file does not log anything.
37 #include "common/common.h"
38 #include <babeltrace2/trace-ir/event-const.h>
39 #include <babeltrace2/trace-ir/packet-const.h>
40 #include <babeltrace2/trace-ir/stream-const.h>
43 #include "assert-pre.h"
44 #include "assert-post.h"
46 #include "object-pool.h"
47 #include "graph/component-class.h"
48 #include "graph/component-class-sink-colander.h"
49 #include "graph/component-filter.h"
50 #include "graph/component.h"
51 #include "graph/component-sink.h"
52 #include "graph/component-source.h"
53 #include "graph/connection.h"
54 #include "graph/graph.h"
55 #include "graph/message/discarded-items.h"
56 #include "graph/message/event.h"
57 #include "graph/message/iterator.h"
58 #include "graph/message/message.h"
59 #include "graph/message/message-iterator-inactivity.h"
60 #include "graph/message/packet.h"
61 #include "graph/message/stream-activity.h"
62 #include "graph/message/stream.h"
63 #include "graph/port.h"
64 #include "plugin/plugin.h"
65 #include "plugin/plugin-so.h"
66 #include "trace-ir/clock-class.h"
67 #include "trace-ir/clock-snapshot.h"
68 #include "trace-ir/event-class.h"
69 #include "trace-ir/event.h"
70 #include "trace-ir/field-class.h"
71 #include "trace-ir/field.h"
72 #include "trace-ir/field-path.h"
73 #include "trace-ir/packet.h"
74 #include "trace-ir/stream-class.h"
75 #include "trace-ir/stream.h"
76 #include "trace-ir/trace-class.h"
77 #include "trace-ir/trace.h"
78 #include "trace-ir/utils.h"
80 #include "assert-pre.h"
82 #define LIB_LOGGING_BUF_SIZE (4096 * 4)
84 static __thread
char lib_logging_buf
[LIB_LOGGING_BUF_SIZE
];
86 #define BUF_APPEND(_fmt, ...) \
89 size_t _size = LIB_LOGGING_BUF_SIZE - \
90 (size_t) (*buf_ch - lib_logging_buf); \
91 _count = snprintf(*buf_ch, _size, (_fmt), __VA_ARGS__); \
92 BT_ASSERT(_count >= 0); \
93 *buf_ch += MIN(_count, _size); \
94 if (*buf_ch >= lib_logging_buf + LIB_LOGGING_BUF_SIZE - 1) { \
99 #define BUF_APPEND_UUID(_uuid) \
101 BUF_APPEND(", %suuid=", prefix); \
102 format_uuid(buf_ch, (_uuid)); \
105 #define PRFIELD(_expr) prefix, (_expr)
107 #define PRFIELD_GSTRING(_expr) PRFIELD((_expr) ? (_expr)->str : NULL)
109 #define TMP_PREFIX_LEN 64
110 #define SET_TMP_PREFIX(_prefix2) \
112 snprintf(tmp_prefix, TMP_PREFIX_LEN - 1, "%s%s", \
113 prefix, (_prefix2)); \
114 tmp_prefix[TMP_PREFIX_LEN - 1] = '\0'; \
117 static inline void format_component(char **buf_ch
, bool extended
,
118 const char *prefix
, const struct bt_component
*component
);
120 static inline void format_port(char **buf_ch
, bool extended
,
121 const char *prefix
, const struct bt_port
*port
);
123 static inline void format_connection(char **buf_ch
, bool extended
,
124 const char *prefix
, const struct bt_connection
*connection
);
126 static inline void format_clock_snapshot(char **buf_ch
, bool extended
,
127 const char *prefix
, const struct bt_clock_snapshot
*clock_snapshot
);
129 static inline void format_field_path(char **buf_ch
, bool extended
,
130 const char *prefix
, const struct bt_field_path
*field_path
);
132 static inline void format_object(char **buf_ch
, bool extended
,
133 const char *prefix
, const struct bt_object
*obj
)
135 BUF_APPEND(", %sref-count=%llu", prefix
, obj
->ref_count
);
138 static inline void format_uuid(char **buf_ch
, bt_uuid uuid
)
140 BUF_APPEND("\"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\"",
141 (unsigned int) uuid
[0],
142 (unsigned int) uuid
[1],
143 (unsigned int) uuid
[2],
144 (unsigned int) uuid
[3],
145 (unsigned int) uuid
[4],
146 (unsigned int) uuid
[5],
147 (unsigned int) uuid
[6],
148 (unsigned int) uuid
[7],
149 (unsigned int) uuid
[8],
150 (unsigned int) uuid
[9],
151 (unsigned int) uuid
[10],
152 (unsigned int) uuid
[11],
153 (unsigned int) uuid
[12],
154 (unsigned int) uuid
[13],
155 (unsigned int) uuid
[14],
156 (unsigned int) uuid
[15]);
159 static inline void format_object_pool(char **buf_ch
, bool extended
,
160 const char *prefix
, const struct bt_object_pool
*pool
)
162 BUF_APPEND(", %ssize=%zu", PRFIELD(pool
->size
));
165 BUF_APPEND(", %scap=%u", PRFIELD(pool
->objects
->len
));
169 static inline void format_integer_field_class(char **buf_ch
,
170 bool extended
, const char *prefix
,
171 const struct bt_field_class
*field_class
)
173 const struct bt_field_class_integer
*int_fc
=
174 (const void *) field_class
;
176 BUF_APPEND(", %srange-size=%" PRIu64
", %sbase=%s",
177 PRFIELD(int_fc
->range
),
178 PRFIELD(bt_common_field_class_integer_preferred_display_base_string(int_fc
->base
)));
181 static inline void format_array_field_class(char **buf_ch
,
182 bool extended
, const char *prefix
,
183 const struct bt_field_class
*field_class
)
185 const struct bt_field_class_array
*array_fc
=
186 (const void *) field_class
;
188 BUF_APPEND(", %selement-fc-addr=%p, %selement-fc-type=%s",
189 PRFIELD(array_fc
->element_fc
),
190 PRFIELD(bt_common_field_class_type_string(array_fc
->element_fc
->type
)));
193 static inline void format_field_class(char **buf_ch
, bool extended
,
194 const char *prefix
, const struct bt_field_class
*field_class
)
196 char tmp_prefix
[TMP_PREFIX_LEN
];
198 BUF_APPEND(", %stype=%s",
199 PRFIELD(bt_common_field_class_type_string(field_class
->type
)));
202 BUF_APPEND(", %sis-frozen=%d", PRFIELD(field_class
->frozen
));
203 BUF_APPEND(", %sis-part-of-trace-class=%d",
204 PRFIELD(field_class
->part_of_trace_class
));
209 switch (field_class
->type
) {
210 case BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER
:
211 case BT_FIELD_CLASS_TYPE_SIGNED_INTEGER
:
213 format_integer_field_class(buf_ch
, extended
, prefix
, field_class
);
216 case BT_FIELD_CLASS_TYPE_REAL
:
218 const struct bt_field_class_real
*real_fc
= (void *) field_class
;
220 BUF_APPEND(", %sis-single-precision=%d",
221 PRFIELD(real_fc
->is_single_precision
));
224 case BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION
:
225 case BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION
:
227 const struct bt_field_class_enumeration
*enum_fc
=
228 (const void *) field_class
;
230 format_integer_field_class(buf_ch
, extended
, prefix
, field_class
);
231 BUF_APPEND(", %smapping-count=%u",
232 PRFIELD(enum_fc
->mappings
->len
));
235 case BT_FIELD_CLASS_TYPE_STRUCTURE
:
237 const struct bt_field_class_structure
*struct_fc
=
238 (const void *) field_class
;
240 if (struct_fc
->common
.named_fcs
) {
241 BUF_APPEND(", %smember-count=%u",
242 PRFIELD(struct_fc
->common
.named_fcs
->len
));
247 case BT_FIELD_CLASS_TYPE_STATIC_ARRAY
:
249 const struct bt_field_class_static_array
*array_fc
=
250 (const void *) field_class
;
252 format_array_field_class(buf_ch
, extended
, prefix
, field_class
);
253 BUF_APPEND(", %slength=%" PRIu64
, PRFIELD(array_fc
->length
));
256 case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY
:
258 const struct bt_field_class_dynamic_array
*array_fc
=
259 (const void *) field_class
;
261 format_array_field_class(buf_ch
, extended
, prefix
, field_class
);
263 if (array_fc
->length_fc
) {
264 SET_TMP_PREFIX("length-fc-");
265 format_field_class(buf_ch
, extended
, tmp_prefix
,
266 array_fc
->length_fc
);
269 if (array_fc
->length_field_path
) {
270 SET_TMP_PREFIX("length-field-path-");
271 format_field_path(buf_ch
, extended
, tmp_prefix
,
272 array_fc
->length_field_path
);
277 case BT_FIELD_CLASS_TYPE_VARIANT
:
279 const struct bt_field_class_variant
*var_fc
=
280 (const void *) field_class
;
282 if (var_fc
->common
.named_fcs
) {
283 BUF_APPEND(", %soption-count=%u",
284 PRFIELD(var_fc
->common
.named_fcs
->len
));
287 if (var_fc
->selector_fc
) {
288 SET_TMP_PREFIX("selector-fc-");
289 format_field_class(buf_ch
, extended
, tmp_prefix
,
290 var_fc
->selector_fc
);
293 if (var_fc
->selector_field_path
) {
294 SET_TMP_PREFIX("selector-field-path-");
295 format_field_path(buf_ch
, extended
, tmp_prefix
,
296 var_fc
->selector_field_path
);
306 static inline void format_field_integer_extended(char **buf_ch
,
307 const char *prefix
, const struct bt_field
*field
)
309 const struct bt_field_integer
*integer
= (void *) field
;
310 const struct bt_field_class_integer
*field_class
=
311 (void *) field
->class;
312 const char *fmt
= NULL
;
314 BT_ASSERT(field_class
);
316 if (field_class
->base
== BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_OCTAL
) {
317 fmt
= ", %svalue=%" PRIo64
;
318 } else if (field_class
->base
== BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_HEXADECIMAL
) {
319 fmt
= ", %svalue=%" PRIx64
;
322 if (field_class
->common
.type
== BT_FIELD_CLASS_TYPE_SIGNED_INTEGER
||
323 field_class
->common
.type
== BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION
) {
325 fmt
= ", %svalue=%" PRId64
;
328 BUF_APPEND(fmt
, PRFIELD(integer
->value
.i
));
331 fmt
= ", %svalue=%" PRIu64
;
334 BUF_APPEND(fmt
, PRFIELD(integer
->value
.u
));
338 static inline void format_field(char **buf_ch
, bool extended
,
339 const char *prefix
, const struct bt_field
*field
)
341 BUF_APPEND(", %sis-set=%d", PRFIELD(field
->is_set
));
344 BUF_APPEND(", %sis-frozen=%d", PRFIELD(field
->frozen
));
347 BUF_APPEND(", %sclass-addr=%p", PRFIELD(field
->class));
353 BUF_APPEND(", %sclass-type=%s",
354 PRFIELD(bt_common_field_class_type_string(field
->class->type
)));
356 if (!extended
|| !field
->is_set
) {
360 switch (field
->class->type
) {
361 case BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER
:
362 case BT_FIELD_CLASS_TYPE_SIGNED_INTEGER
:
363 case BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION
:
364 case BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION
:
366 format_field_integer_extended(buf_ch
, prefix
, field
);
369 case BT_FIELD_CLASS_TYPE_REAL
:
371 const struct bt_field_real
*real_field
= (const void *) field
;
373 BUF_APPEND(", %svalue=%f", PRFIELD(real_field
->value
));
376 case BT_FIELD_CLASS_TYPE_STRING
:
378 const struct bt_field_string
*str
= (const void *) field
;
381 BT_ASSERT(str
->buf
->data
);
382 BUF_APPEND(", %spartial-value=\"%.32s\"",
383 PRFIELD(str
->buf
->data
));
388 case BT_FIELD_CLASS_TYPE_STATIC_ARRAY
:
389 case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY
:
391 const struct bt_field_array
*array_field
= (const void *) field
;
393 BUF_APPEND(", %slength=%" PRIu64
, PRFIELD(array_field
->length
));
395 if (array_field
->fields
) {
396 BUF_APPEND(", %sallocated-length=%u",
397 PRFIELD(array_field
->fields
->len
));
402 case BT_FIELD_CLASS_TYPE_VARIANT
:
404 const struct bt_field_variant
*var_field
= (const void *) field
;
406 BUF_APPEND(", %sselected-field-index=%" PRIu64
,
407 PRFIELD(var_field
->selected_index
));
415 static inline void format_field_path(char **buf_ch
, bool extended
,
416 const char *prefix
, const struct bt_field_path
*field_path
)
420 if (field_path
->items
) {
421 BT_ASSERT(field_path
->items
);
422 BUF_APPEND(", %sitem-count=%u",
423 PRFIELD(field_path
->items
->len
));
426 if (!extended
|| !field_path
->items
) {
430 BUF_APPEND(", %spath=[%s",
431 PRFIELD(bt_common_scope_string(field_path
->root
)));
433 for (i
= 0; i
< bt_field_path_get_item_count(field_path
); i
++) {
434 const struct bt_field_path_item
*fp_item
=
435 bt_field_path_borrow_item_by_index_const(field_path
, i
);
437 switch (bt_field_path_item_get_type(fp_item
)) {
438 case BT_FIELD_PATH_ITEM_TYPE_INDEX
:
439 BUF_APPEND(", %" PRIu64
,
440 bt_field_path_item_index_get_index(fp_item
));
442 case BT_FIELD_PATH_ITEM_TYPE_CURRENT_ARRAY_ELEMENT
:
443 BUF_APPEND("%s", ", <CUR>");
450 BUF_APPEND("%s", "]");
453 static inline void format_trace_class(char **buf_ch
, bool extended
,
454 const char *prefix
, const struct bt_trace_class
*trace_class
)
456 if (trace_class
->name
.value
) {
457 BUF_APPEND(", %sname=\"%s\"",
458 PRFIELD(trace_class
->name
.value
));
465 BUF_APPEND(", %sis-frozen=%d", PRFIELD(trace_class
->frozen
));
467 if (trace_class
->uuid
.value
) {
468 BUF_APPEND_UUID(trace_class
->uuid
.value
);
471 if (trace_class
->stream_classes
) {
472 BUF_APPEND(", %sstream-class-count=%u",
473 PRFIELD(trace_class
->stream_classes
->len
));
476 BUF_APPEND(", %sassigns-auto-sc-id=%d",
477 PRFIELD(trace_class
->assigns_automatic_stream_class_id
));
480 static inline void format_trace(char **buf_ch
, bool extended
,
481 const char *prefix
, const struct bt_trace
*trace
)
483 char tmp_prefix
[TMP_PREFIX_LEN
];
485 if (trace
->name
.value
) {
486 BUF_APPEND(", %sname=\"%s\"", PRFIELD(trace
->name
.value
));
493 BUF_APPEND(", %sis-frozen=%d", PRFIELD(trace
->frozen
));
495 if (trace
->streams
) {
496 BUF_APPEND(", %sstream-count=%u",
497 PRFIELD(trace
->streams
->len
));
504 BUF_APPEND(", %strace-class-addr=%p", PRFIELD(trace
->class));
505 SET_TMP_PREFIX("trace-class-");
506 format_trace_class(buf_ch
, false, tmp_prefix
, trace
->class);
509 static inline void format_stream_class(char **buf_ch
, bool extended
,
511 const struct bt_stream_class
*stream_class
)
513 const struct bt_trace_class
*trace_class
;
514 char tmp_prefix
[TMP_PREFIX_LEN
];
516 BUF_APPEND(", %sid=%" PRIu64
, PRFIELD(stream_class
->id
));
518 if (stream_class
->name
.value
) {
519 BUF_APPEND(", %sname=\"%s\"",
520 PRFIELD(stream_class
->name
.value
));
527 BUF_APPEND(", %sis-frozen=%d", PRFIELD(stream_class
->frozen
));
529 if (stream_class
->event_classes
) {
530 BUF_APPEND(", %sevent-class-count=%u",
531 PRFIELD(stream_class
->event_classes
->len
));
534 BUF_APPEND(", %spacket-context-fc-addr=%p, "
535 "%sevent-common-context-fc-addr=%p",
536 PRFIELD(stream_class
->packet_context_fc
),
537 PRFIELD(stream_class
->event_common_context_fc
));
538 trace_class
= bt_stream_class_borrow_trace_class_inline(stream_class
);
543 BUF_APPEND(", %sassigns-auto-ec-id=%d, %sassigns-auto-stream-id=%d, "
544 "%spackets-have-default-beginning-cs=%d, "
545 "%spackets-have-default-end-cs=%d, "
546 "%ssupports-discarded-events=%d, "
547 "%sdiscarded-events-have-default-cs=%d, "
548 "%ssupports-discarded-packets=%d, "
549 "%sdiscarded-packets-have-default-cs=%d",
550 PRFIELD(stream_class
->assigns_automatic_event_class_id
),
551 PRFIELD(stream_class
->assigns_automatic_stream_id
),
552 PRFIELD(stream_class
->packets_have_beginning_default_clock_snapshot
),
553 PRFIELD(stream_class
->packets_have_end_default_clock_snapshot
),
554 PRFIELD(stream_class
->supports_discarded_events
),
555 PRFIELD(stream_class
->discarded_events_have_default_clock_snapshots
),
556 PRFIELD(stream_class
->supports_discarded_packets
),
557 PRFIELD(stream_class
->discarded_packets_have_default_clock_snapshots
));
558 BUF_APPEND(", %strace-class-addr=%p", PRFIELD(trace_class
));
559 SET_TMP_PREFIX("trace-class-");
560 format_trace_class(buf_ch
, false, tmp_prefix
, trace_class
);
561 SET_TMP_PREFIX("pcf-pool-");
562 format_object_pool(buf_ch
, extended
, tmp_prefix
,
563 &stream_class
->packet_context_field_pool
);
566 static inline void format_event_class(char **buf_ch
, bool extended
,
567 const char *prefix
, const struct bt_event_class
*event_class
)
569 const struct bt_stream_class
*stream_class
;
570 const struct bt_trace_class
*trace_class
;
571 char tmp_prefix
[TMP_PREFIX_LEN
];
573 BUF_APPEND(", %sid=%" PRIu64
, PRFIELD(event_class
->id
));
575 if (event_class
->name
.value
) {
576 BUF_APPEND(", %sname=\"%s\"",
577 PRFIELD(event_class
->name
.value
));
584 BUF_APPEND(", %sis-frozen=%d", PRFIELD(event_class
->frozen
));
586 if (event_class
->log_level
.base
.avail
) {
587 BUF_APPEND(", %slog-level=%s",
588 PRFIELD(bt_common_event_class_log_level_string(
589 (int) event_class
->log_level
.value
)));
592 if (event_class
->emf_uri
.value
) {
593 BUF_APPEND(", %semf-uri=\"%s\"",
594 PRFIELD(event_class
->emf_uri
.value
));
597 BUF_APPEND(", %sspecific-context-fc-addr=%p, %spayload-fc-addr=%p",
598 PRFIELD(event_class
->specific_context_fc
),
599 PRFIELD(event_class
->payload_fc
));
601 stream_class
= bt_event_class_borrow_stream_class_const(event_class
);
606 BUF_APPEND(", %sstream-class-addr=%p", PRFIELD(stream_class
));
607 SET_TMP_PREFIX("stream-class-");
608 format_stream_class(buf_ch
, false, tmp_prefix
, stream_class
);
609 trace_class
= bt_stream_class_borrow_trace_class_inline(stream_class
);
614 BUF_APPEND(", %strace-class-addr=%p", PRFIELD(trace_class
));
615 SET_TMP_PREFIX("trace-class-");
616 format_trace_class(buf_ch
, false, tmp_prefix
, trace_class
);
617 SET_TMP_PREFIX("event-pool-");
618 format_object_pool(buf_ch
, extended
, tmp_prefix
,
619 &event_class
->event_pool
);
622 static inline void format_stream(char **buf_ch
, bool extended
,
623 const char *prefix
, const struct bt_stream
*stream
)
625 const struct bt_stream_class
*stream_class
;
626 const struct bt_trace_class
*trace_class
= NULL
;
627 const struct bt_trace
*trace
= NULL
;
628 char tmp_prefix
[TMP_PREFIX_LEN
];
630 BUF_APPEND(", %sid=%" PRIu64
, PRFIELD(stream
->id
));
632 if (stream
->name
.value
) {
633 BUF_APPEND(", %sname=\"%s\"", PRFIELD(stream
->name
.value
));
640 stream_class
= bt_stream_borrow_class_const(stream
);
642 BUF_APPEND(", %sstream-class-addr=%p", PRFIELD(stream_class
));
643 SET_TMP_PREFIX("stream-class-");
644 format_stream_class(buf_ch
, false, tmp_prefix
, stream_class
);
645 trace_class
= bt_stream_class_borrow_trace_class_inline(stream_class
);
649 BUF_APPEND(", %strace-class-addr=%p", PRFIELD(trace_class
));
650 SET_TMP_PREFIX("trace-class-");
651 format_trace_class(buf_ch
, false, tmp_prefix
, trace_class
);
654 trace
= bt_stream_borrow_trace_inline(stream
);
656 BUF_APPEND(", %strace-addr=%p", PRFIELD(trace
));
657 SET_TMP_PREFIX("trace-");
658 format_trace(buf_ch
, false, tmp_prefix
, trace
);
661 SET_TMP_PREFIX("packet-pool-");
662 format_object_pool(buf_ch
, extended
, tmp_prefix
, &stream
->packet_pool
);
665 static inline void format_packet(char **buf_ch
, bool extended
,
666 const char *prefix
, const struct bt_packet
*packet
)
668 const struct bt_stream
*stream
;
669 const struct bt_trace_class
*trace_class
;
670 char tmp_prefix
[TMP_PREFIX_LEN
];
676 BUF_APPEND(", %sis-frozen=%d, %scontext-field-addr=%p",
677 PRFIELD(packet
->frozen
),
678 PRFIELD(packet
->context_field
? packet
->context_field
->field
: NULL
));
679 stream
= bt_packet_borrow_stream_const(packet
);
684 BUF_APPEND(", %sstream-addr=%p", PRFIELD(stream
));
685 SET_TMP_PREFIX("stream-");
686 format_stream(buf_ch
, false, tmp_prefix
, stream
);
687 trace_class
= (const struct bt_trace_class
*) bt_object_borrow_parent(&stream
->base
);
692 BUF_APPEND(", %strace-class-addr=%p", PRFIELD(trace_class
));
693 SET_TMP_PREFIX("trace-class-");
694 format_trace_class(buf_ch
, false, tmp_prefix
, trace_class
);
697 static inline void format_event(char **buf_ch
, bool extended
,
698 const char *prefix
, const struct bt_event
*event
)
700 const struct bt_packet
*packet
;
701 const struct bt_stream
*stream
;
702 const struct bt_trace_class
*trace_class
;
703 const struct bt_stream_class
*stream_class
;
704 char tmp_prefix
[TMP_PREFIX_LEN
];
710 BUF_APPEND(", %sis-frozen=%d, "
711 "%scommon-context-field-addr=%p, "
712 "%sspecific-context-field-addr=%p, "
713 "%spayload-field-addr=%p, ",
714 PRFIELD(event
->frozen
),
715 PRFIELD(event
->common_context_field
),
716 PRFIELD(event
->specific_context_field
),
717 PRFIELD(event
->payload_field
));
718 BUF_APPEND(", %sevent-class-addr=%p", PRFIELD(event
->class));
724 SET_TMP_PREFIX("event-class-");
725 format_event_class(buf_ch
, false, tmp_prefix
, event
->class);
726 stream_class
= bt_event_class_borrow_stream_class(event
->class);
728 BUF_APPEND(", %sstream-class-addr=%p", PRFIELD(stream_class
));
729 SET_TMP_PREFIX("stream-class-");
730 format_stream_class(buf_ch
, false, tmp_prefix
,
733 trace_class
= bt_stream_class_borrow_trace_class_inline(
736 BUF_APPEND(", %strace-class-addr=%p",
737 PRFIELD(trace_class
));
738 SET_TMP_PREFIX("trace-class-");
739 format_trace_class(buf_ch
, false, tmp_prefix
,
744 packet
= bt_event_borrow_packet_const(event
);
749 BUF_APPEND(", %spacket-addr=%p", PRFIELD(packet
));
750 SET_TMP_PREFIX("packet-");
751 format_packet(buf_ch
, false, tmp_prefix
, packet
);
752 stream
= bt_packet_borrow_stream_const(packet
);
757 BUF_APPEND(", %sstream-addr=%p", PRFIELD(stream
));
758 SET_TMP_PREFIX("stream-");
759 format_stream(buf_ch
, false, tmp_prefix
, stream
);
762 static inline void format_clock_class(char **buf_ch
, bool extended
,
763 const char *prefix
, const struct bt_clock_class
*clock_class
)
765 char tmp_prefix
[TMP_PREFIX_LEN
];
767 if (clock_class
->name
.value
) {
768 BUF_APPEND(", %sname=\"%s\"", PRFIELD(clock_class
->name
.value
));
771 BUF_APPEND(", %sfreq=%" PRIu64
, PRFIELD(clock_class
->frequency
));
777 if (clock_class
->description
.value
) {
778 BUF_APPEND(", %spartial-descr=\"%.32s\"",
779 PRFIELD(clock_class
->description
.value
));
782 if (clock_class
->uuid
.value
) {
783 BUF_APPEND_UUID(clock_class
->uuid
.value
);
786 BUF_APPEND(", %sis-frozen=%d, %sprecision=%" PRIu64
", "
787 "%soffset-s=%" PRId64
", "
788 "%soffset-cycles=%" PRIu64
", %sorigin-is-unix-epoch=%d, "
789 "%sbase-offset-ns=%" PRId64
,
790 PRFIELD(clock_class
->frozen
), PRFIELD(clock_class
->precision
),
791 PRFIELD(clock_class
->offset_seconds
),
792 PRFIELD(clock_class
->offset_cycles
),
793 PRFIELD(clock_class
->origin_is_unix_epoch
),
794 PRFIELD(clock_class
->base_offset
.value_ns
));
796 SET_TMP_PREFIX("cs-pool-");
797 format_object_pool(buf_ch
, extended
, tmp_prefix
,
798 &clock_class
->cs_pool
);
801 static inline void format_clock_snapshot(char **buf_ch
, bool extended
,
802 const char *prefix
, const struct bt_clock_snapshot
*clock_snapshot
)
804 char tmp_prefix
[TMP_PREFIX_LEN
];
805 BUF_APPEND(", %svalue=%" PRIu64
", %sns-from-origin=%" PRId64
,
806 PRFIELD(clock_snapshot
->value_cycles
),
807 PRFIELD(clock_snapshot
->ns_from_origin
));
813 BUF_APPEND(", %sis-set=%d", PRFIELD(clock_snapshot
->is_set
));
815 if (clock_snapshot
->clock_class
) {
816 BUF_APPEND(", %sclock-class-addr=%p",
817 PRFIELD(clock_snapshot
->clock_class
));
818 SET_TMP_PREFIX("clock-class-");
819 format_clock_class(buf_ch
, false, tmp_prefix
,
820 clock_snapshot
->clock_class
);
824 static inline void format_value(char **buf_ch
, bool extended
,
825 const char *prefix
, const struct bt_value
*value
)
827 BUF_APPEND(", %stype=%s",
828 PRFIELD(bt_common_value_type_string(bt_value_get_type(value
))));
834 switch (bt_value_get_type(value
)) {
835 case BT_VALUE_TYPE_BOOL
:
837 bt_bool val
= bt_value_bool_get(value
);
839 BUF_APPEND(", %svalue=%d", PRFIELD(val
));
842 case BT_VALUE_TYPE_UNSIGNED_INTEGER
:
844 BUF_APPEND(", %svalue=%" PRIu64
,
845 PRFIELD(bt_value_unsigned_integer_get(value
)));
848 case BT_VALUE_TYPE_SIGNED_INTEGER
:
850 BUF_APPEND(", %svalue=%" PRId64
,
851 PRFIELD(bt_value_signed_integer_get(value
)));
854 case BT_VALUE_TYPE_REAL
:
856 double val
= bt_value_real_get(value
);
858 BUF_APPEND(", %svalue=%f", PRFIELD(val
));
861 case BT_VALUE_TYPE_STRING
:
863 const char *val
= bt_value_string_get(value
);
865 BUF_APPEND(", %spartial-value=\"%.32s\"", PRFIELD(val
));
868 case BT_VALUE_TYPE_ARRAY
:
870 int64_t count
= bt_value_array_get_size(value
);
872 BT_ASSERT(count
>= 0);
873 BUF_APPEND(", %selement-count=%" PRId64
, PRFIELD(count
));
876 case BT_VALUE_TYPE_MAP
:
878 int64_t count
= bt_value_map_get_size(value
);
880 BT_ASSERT(count
>= 0);
881 BUF_APPEND(", %selement-count=%" PRId64
, PRFIELD(count
));
889 static inline void format_message(char **buf_ch
, bool extended
,
890 const char *prefix
, const struct bt_message
*msg
)
892 char tmp_prefix
[TMP_PREFIX_LEN
];
894 BUF_APPEND(", %stype=%s",
895 PRFIELD(bt_message_type_string(msg
->type
)));
901 BUF_APPEND(", %sis-frozen=%d, %sgraph-addr=%p",
902 PRFIELD(msg
->frozen
), PRFIELD(msg
->graph
));
905 case BT_MESSAGE_TYPE_EVENT
:
907 const struct bt_message_event
*msg_event
=
910 if (msg_event
->event
) {
911 SET_TMP_PREFIX("event-");
912 format_event(buf_ch
, true, tmp_prefix
,
916 if (msg_event
->default_cs
) {
917 SET_TMP_PREFIX("default-cs-");
918 format_clock_snapshot(buf_ch
, true, tmp_prefix
,
919 msg_event
->default_cs
);
924 case BT_MESSAGE_TYPE_STREAM_BEGINNING
:
925 case BT_MESSAGE_TYPE_STREAM_END
:
927 const struct bt_message_stream
*msg_stream
= (const void *) msg
;
929 if (msg_stream
->stream
) {
930 SET_TMP_PREFIX("stream-");
931 format_stream(buf_ch
, true, tmp_prefix
,
937 case BT_MESSAGE_TYPE_STREAM_ACTIVITY_BEGINNING
:
938 case BT_MESSAGE_TYPE_STREAM_ACTIVITY_END
:
940 const struct bt_message_stream_activity
*msg_stream_activity
=
943 if (msg_stream_activity
->stream
) {
944 SET_TMP_PREFIX("stream-");
945 format_stream(buf_ch
, true, tmp_prefix
,
946 msg_stream_activity
->stream
);
949 BUF_APPEND(", %sdefault-cs-state=%s",
950 PRFIELD(bt_message_stream_activity_clock_snapshot_state_string(
951 msg_stream_activity
->default_cs_state
)));
953 if (msg_stream_activity
->default_cs
) {
954 SET_TMP_PREFIX("default-cs-");
955 format_clock_snapshot(buf_ch
, true, tmp_prefix
,
956 msg_stream_activity
->default_cs
);
961 case BT_MESSAGE_TYPE_PACKET_BEGINNING
:
962 case BT_MESSAGE_TYPE_PACKET_END
:
964 const struct bt_message_packet
*msg_packet
= (const void *) msg
;
966 if (msg_packet
->packet
) {
967 SET_TMP_PREFIX("packet-");
968 format_packet(buf_ch
, true, tmp_prefix
,
972 if (msg_packet
->default_cs
) {
973 SET_TMP_PREFIX("default-cs-");
974 format_clock_snapshot(buf_ch
, true, tmp_prefix
,
975 msg_packet
->default_cs
);
980 case BT_MESSAGE_TYPE_DISCARDED_EVENTS
:
981 case BT_MESSAGE_TYPE_DISCARDED_PACKETS
:
983 const struct bt_message_discarded_items
*msg_disc_items
=
986 if (msg_disc_items
->stream
) {
987 SET_TMP_PREFIX("stream-");
988 format_stream(buf_ch
, true, tmp_prefix
,
989 msg_disc_items
->stream
);
992 if (msg_disc_items
->default_begin_cs
) {
993 SET_TMP_PREFIX("default-begin-cs-");
994 format_clock_snapshot(buf_ch
, true, tmp_prefix
,
995 msg_disc_items
->default_begin_cs
);
998 if (msg_disc_items
->default_end_cs
) {
999 SET_TMP_PREFIX("default-end-cs-");
1000 format_clock_snapshot(buf_ch
, true, tmp_prefix
,
1001 msg_disc_items
->default_end_cs
);
1004 if (msg_disc_items
->count
.base
.avail
) {
1005 BUF_APPEND(", %scount=%" PRIu64
,
1006 PRFIELD(msg_disc_items
->count
.value
));
1016 static inline void format_plugin_so_shared_lib_handle(char **buf_ch
,
1018 const struct bt_plugin_so_shared_lib_handle
*handle
)
1020 BUF_APPEND(", %saddr=%p", PRFIELD(handle
));
1023 BUF_APPEND(", %spath=\"%s\"", PRFIELD_GSTRING(handle
->path
));
1027 static inline void format_component_class(char **buf_ch
, bool extended
,
1029 const struct bt_component_class
*comp_class
)
1031 char tmp_prefix
[TMP_PREFIX_LEN
];
1033 BUF_APPEND(", %stype=%s, %sname=\"%s\"",
1034 PRFIELD(bt_component_class_type_string(comp_class
->type
)),
1035 PRFIELD_GSTRING(comp_class
->name
));
1037 if (comp_class
->description
) {
1038 BUF_APPEND(", %spartial-descr=\"%.32s\"",
1039 PRFIELD_GSTRING(comp_class
->description
));
1046 BUF_APPEND(", %sis-frozen=%d", PRFIELD(comp_class
->frozen
));
1048 if (comp_class
->so_handle
) {
1049 SET_TMP_PREFIX("so-handle-");
1050 format_plugin_so_shared_lib_handle(buf_ch
, tmp_prefix
,
1051 comp_class
->so_handle
);
1055 static inline void format_component(char **buf_ch
, bool extended
,
1056 const char *prefix
, const struct bt_component
*component
)
1058 char tmp_prefix
[TMP_PREFIX_LEN
];
1060 BUF_APPEND(", %sname=\"%s\", %slog-level=%s",
1061 PRFIELD_GSTRING(component
->name
),
1062 PRFIELD(bt_common_logging_level_string(component
->log_level
)));
1064 if (component
->class) {
1065 SET_TMP_PREFIX("class-");
1066 format_component_class(buf_ch
, extended
, tmp_prefix
,
1074 if (component
->input_ports
) {
1075 BUF_APPEND(", %sinput-port-count=%u",
1076 PRFIELD(component
->input_ports
->len
));
1079 if (component
->output_ports
) {
1080 BUF_APPEND(", %soutput-port-count=%u",
1081 PRFIELD(component
->output_ports
->len
));
1085 static inline void format_port(char **buf_ch
, bool extended
,
1086 const char *prefix
, const struct bt_port
*port
)
1088 char tmp_prefix
[TMP_PREFIX_LEN
];
1090 BUF_APPEND(", %stype=%s, %sname=\"%s\"",
1091 PRFIELD(bt_port_type_string(port
->type
)),
1092 PRFIELD_GSTRING(port
->name
));
1098 if (port
->connection
) {
1099 SET_TMP_PREFIX("conn-");
1100 format_connection(buf_ch
, false, tmp_prefix
, port
->connection
);
1104 static inline void format_connection(char **buf_ch
, bool extended
,
1105 const char *prefix
, const struct bt_connection
*connection
)
1107 char tmp_prefix
[TMP_PREFIX_LEN
];
1113 if (connection
->upstream_port
) {
1114 SET_TMP_PREFIX("upstream-port-");
1115 format_port(buf_ch
, false, tmp_prefix
,
1116 connection
->upstream_port
);
1119 if (connection
->downstream_port
) {
1120 SET_TMP_PREFIX("downstream-port-");
1121 format_port(buf_ch
, false, tmp_prefix
,
1122 connection
->downstream_port
);
1126 static inline void format_graph(char **buf_ch
, bool extended
,
1127 const char *prefix
, const struct bt_graph
*graph
)
1129 char tmp_prefix
[TMP_PREFIX_LEN
];
1131 BUF_APPEND(", %sis-canceled=%d, %scan-consume=%d, "
1132 "%sconfig-state=%s",
1133 PRFIELD(graph
->canceled
),
1134 PRFIELD(graph
->can_consume
),
1135 PRFIELD(bt_graph_configuration_state_string(graph
->config_state
)));
1141 if (graph
->components
) {
1142 BUF_APPEND(", %scomp-count=%u",
1143 PRFIELD(graph
->components
->len
));
1146 if (graph
->connections
) {
1147 BUF_APPEND(", %sconn-count=%u",
1148 PRFIELD(graph
->connections
->len
));
1151 SET_TMP_PREFIX("en-pool-");
1152 format_object_pool(buf_ch
, extended
, tmp_prefix
,
1153 &graph
->event_msg_pool
);
1154 SET_TMP_PREFIX("pbn-pool-");
1155 format_object_pool(buf_ch
, extended
, tmp_prefix
,
1156 &graph
->packet_begin_msg_pool
);
1157 SET_TMP_PREFIX("pen-pool-");
1158 format_object_pool(buf_ch
, extended
, tmp_prefix
,
1159 &graph
->packet_end_msg_pool
);
1162 static inline void format_message_iterator(char **buf_ch
,
1163 bool extended
, const char *prefix
,
1164 const struct bt_message_iterator
*iterator
)
1167 char tmp_prefix
[TMP_PREFIX_LEN
];
1169 if (iterator
->type
== BT_MESSAGE_ITERATOR_TYPE_SELF_COMPONENT_PORT_INPUT
) {
1170 type
= "BT_MESSAGE_ITERATOR_TYPE_SELF_COMPONENT_PORT_INPUT";
1171 } else if (iterator
->type
== BT_MESSAGE_ITERATOR_TYPE_PORT_OUTPUT
) {
1172 type
= "BT_MESSAGE_ITERATOR_TYPE_PORT_OUTPUT";
1177 BUF_APPEND(", %stype=%s", PRFIELD(type
));
1179 switch (iterator
->type
) {
1180 case BT_MESSAGE_ITERATOR_TYPE_SELF_COMPONENT_PORT_INPUT
:
1182 const struct bt_self_component_port_input_message_iterator
*
1183 port_in_iter
= (const void *) iterator
;
1185 if (port_in_iter
->upstream_component
) {
1186 SET_TMP_PREFIX("upstream-comp-");
1187 format_component(buf_ch
, false, tmp_prefix
,
1188 port_in_iter
->upstream_component
);
1191 if (port_in_iter
->upstream_port
) {
1192 SET_TMP_PREFIX("upstream-port-");
1193 format_port(buf_ch
, false, tmp_prefix
,
1194 port_in_iter
->upstream_port
);
1197 if (port_in_iter
->connection
) {
1198 SET_TMP_PREFIX("upstream-conn-");
1199 format_connection(buf_ch
, false, tmp_prefix
,
1200 port_in_iter
->connection
);
1204 case BT_MESSAGE_ITERATOR_TYPE_PORT_OUTPUT
:
1206 const struct bt_port_output_message_iterator
*port_out_iter
=
1207 (const void *) iterator
;
1209 if (port_out_iter
->graph
) {
1210 SET_TMP_PREFIX("graph-");
1211 format_graph(buf_ch
, false, tmp_prefix
,
1212 port_out_iter
->graph
);
1215 if (port_out_iter
->colander
) {
1216 SET_TMP_PREFIX("colander-comp-");
1217 format_component(buf_ch
, false, tmp_prefix
,
1218 (void *) port_out_iter
->colander
);
1228 static inline void format_plugin(char **buf_ch
, bool extended
,
1229 const char *prefix
, const struct bt_plugin
*plugin
)
1231 char tmp_prefix
[TMP_PREFIX_LEN
];
1233 BUF_APPEND(", %stype=%s", PRFIELD(bt_plugin_type_string(plugin
->type
)));
1235 if (plugin
->info
.path_set
) {
1236 BUF_APPEND(", %spath=\"%s\"",
1237 PRFIELD_GSTRING(plugin
->info
.path
));
1240 if (plugin
->info
.name_set
) {
1241 BUF_APPEND(", %sname=\"%s\"",
1242 PRFIELD_GSTRING(plugin
->info
.name
));
1249 if (plugin
->info
.author_set
) {
1250 BUF_APPEND(", %sauthor=\"%s\"",
1251 PRFIELD_GSTRING(plugin
->info
.author
));
1254 if (plugin
->info
.license_set
) {
1255 BUF_APPEND(", %slicense=\"%s\"",
1256 PRFIELD_GSTRING(plugin
->info
.license
));
1259 if (plugin
->info
.version_set
) {
1260 BUF_APPEND(", %sversion=%u.%u.%u%s",
1261 PRFIELD(plugin
->info
.version
.major
),
1262 plugin
->info
.version
.minor
,
1263 plugin
->info
.version
.patch
,
1264 plugin
->info
.version
.extra
?
1265 plugin
->info
.version
.extra
->str
: "");
1268 BUF_APPEND(", %ssrc-comp-class-count=%u, %sflt-comp-class-count=%u, "
1269 "%ssink-comp-class-count=%u",
1270 PRFIELD(plugin
->src_comp_classes
->len
),
1271 PRFIELD(plugin
->flt_comp_classes
->len
),
1272 PRFIELD(plugin
->sink_comp_classes
->len
));
1274 if (plugin
->spec_data
) {
1275 const struct bt_plugin_so_spec_data
*spec_data
=
1276 (const void *) plugin
->spec_data
;
1278 if (spec_data
->shared_lib_handle
) {
1279 SET_TMP_PREFIX("so-handle-");
1280 format_plugin_so_shared_lib_handle(buf_ch
, tmp_prefix
,
1281 spec_data
->shared_lib_handle
);
1286 static inline void format_error_cause(char **buf_ch
, bool extended
,
1287 const char *prefix
, const struct bt_error_cause
*cause
)
1289 const struct bt_error_cause_component_class_id
*comp_class_id
= NULL
;
1291 BUF_APPEND(", %sactor-type=%s, %smodule-name=\"%s\"",
1292 PRFIELD(bt_error_cause_actor_type_string(cause
->actor_type
)),
1293 PRFIELD_GSTRING(cause
->module_name
));
1299 BUF_APPEND(", %spartial-msg=\"%.32s\"",
1300 PRFIELD_GSTRING(cause
->message
));
1302 switch (cause
->actor_type
) {
1303 case BT_ERROR_CAUSE_ACTOR_TYPE_COMPONENT
:
1305 const struct bt_error_cause_component_actor
*spec_cause
=
1306 (const void *) cause
;
1308 BUF_APPEND(", %scomp-name=\"%s\"",
1309 PRFIELD_GSTRING(spec_cause
->comp_name
));
1310 comp_class_id
= &spec_cause
->comp_class_id
;
1313 case BT_ERROR_CAUSE_ACTOR_TYPE_COMPONENT_CLASS
:
1315 const struct bt_error_cause_component_class_actor
*spec_cause
=
1316 (const void *) cause
;
1318 comp_class_id
= &spec_cause
->comp_class_id
;
1321 case BT_ERROR_CAUSE_ACTOR_TYPE_MESSAGE_ITERATOR
:
1323 const struct bt_error_cause_message_iterator_actor
*spec_cause
=
1324 (const void *) cause
;
1326 BUF_APPEND(", %scomp-name=\"%s\", %scomp-out-port-name=\"%s\"",
1327 PRFIELD_GSTRING(spec_cause
->comp_name
),
1328 PRFIELD_GSTRING(spec_cause
->output_port_name
));
1329 comp_class_id
= &spec_cause
->comp_class_id
;
1336 if (comp_class_id
) {
1337 BUF_APPEND(", %scomp-cls-type=%s, %scomp-cls-name=\"%s\", "
1338 "%splugin-name=\"%s\"",
1339 PRFIELD(bt_component_class_type_string(
1340 comp_class_id
->type
)),
1341 PRFIELD_GSTRING(comp_class_id
->name
),
1342 PRFIELD_GSTRING(comp_class_id
->plugin_name
));
1346 static inline void handle_conversion_specifier_bt(void *priv_data
,
1347 char **buf_ch
, size_t avail_size
,
1348 const char **out_fmt_ch
, va_list *args
)
1350 const char *fmt_ch
= *out_fmt_ch
;
1351 bool extended
= false;
1353 char *prefix_ch
= prefix
;
1359 if (*fmt_ch
== 'u') {
1361 obj
= va_arg(*args
, void *);
1362 format_uuid(buf_ch
, obj
);
1366 if (*fmt_ch
== '[') {
1371 if (*fmt_ch
== ']') {
1377 *prefix_ch
= *fmt_ch
;
1385 if (*fmt_ch
== '+') {
1390 obj
= va_arg(*args
, void *);
1391 BUF_APPEND("%saddr=%p", prefix
, obj
);
1399 format_field_class(buf_ch
, extended
, prefix
, obj
);
1402 format_field(buf_ch
, extended
, prefix
, obj
);
1405 format_field_path(buf_ch
, extended
, prefix
, obj
);
1408 format_event_class(buf_ch
, extended
, prefix
, obj
);
1411 format_event(buf_ch
, extended
, prefix
, obj
);
1414 format_stream_class(buf_ch
, extended
, prefix
, obj
);
1417 format_stream(buf_ch
, extended
, prefix
, obj
);
1420 format_packet(buf_ch
, extended
, prefix
, obj
);
1423 format_trace(buf_ch
, extended
, prefix
, obj
);
1426 format_trace_class(buf_ch
, extended
, prefix
, obj
);
1429 format_clock_class(buf_ch
, extended
, prefix
, obj
);
1432 format_clock_snapshot(buf_ch
, extended
, prefix
, obj
);
1435 format_value(buf_ch
, extended
, prefix
, obj
);
1438 format_message(buf_ch
, extended
, prefix
, obj
);
1441 format_message_iterator(buf_ch
, extended
, prefix
, obj
);
1444 format_component_class(buf_ch
, extended
, prefix
, obj
);
1447 format_component(buf_ch
, extended
, prefix
, obj
);
1450 format_port(buf_ch
, extended
, prefix
, obj
);
1453 format_connection(buf_ch
, extended
, prefix
, obj
);
1456 format_plugin(buf_ch
, extended
, prefix
, obj
);
1459 format_graph(buf_ch
, extended
, prefix
, obj
);
1462 format_object_pool(buf_ch
, extended
, prefix
, obj
);
1465 format_object(buf_ch
, extended
, prefix
, obj
);
1468 format_error_cause(buf_ch
, extended
, prefix
, obj
);
1476 *out_fmt_ch
= fmt_ch
;
1479 void bt_lib_log(const char *func
, const char *file
, unsigned line
,
1480 int lvl
, const char *tag
, const char *fmt
, ...)
1485 va_start(args
, fmt
);
1486 bt_common_custom_vsnprintf(lib_logging_buf
, LIB_LOGGING_BUF_SIZE
, '!',
1487 handle_conversion_specifier_bt
, NULL
, fmt
, &args
);
1489 _bt_log_write_d(func
, file
, line
, lvl
, tag
, "%s", lib_logging_buf
);