doc/api/libbabeltrace2/DoxygenLayout.xml: use `topics` tab
[babeltrace.git] / src / lib / lib-logging.c
index 1730f6d09c93588f43f2388da579b0b820daa2e6..6d98a0ce5e0dc38d87949f20e6559c27000dd01b 100644 (file)
 #include <babeltrace2/babeltrace.h>
 
 #include "logging.h"
-#include "assert-cond.h"
 #include "value.h"
 #include "integer-range-set.h"
 #include "object-pool.h"
 #include "graph/interrupter.h"
 #include "graph/component-class.h"
-#include "graph/component-filter.h"
 #include "graph/component.h"
-#include "graph/component-sink.h"
-#include "graph/component-source.h"
 #include "graph/connection.h"
 #include "graph/graph.h"
+#include "graph/iterator.h"
 #include "graph/message/discarded-items.h"
 #include "graph/message/event.h"
-#include "graph/message/iterator.h"
 #include "graph/message/message.h"
-#include "graph/message/message-iterator-inactivity.h"
 #include "graph/message/packet.h"
 #include "graph/message/stream.h"
 #include "graph/port.h"
@@ -55,7 +50,6 @@
 #include "trace-ir/stream.h"
 #include "trace-ir/trace-class.h"
 #include "trace-ir/trace.h"
-#include "trace-ir/utils.h"
 #include "error.h"
 
 #define LIB_LOGGING_BUF_SIZE   (4096 * 4)
@@ -114,8 +108,8 @@ static inline void format_clock_snapshot(char **buf_ch, bool extended,
 static inline void format_field_path(char **buf_ch, bool extended,
                const char *prefix, const struct bt_field_path *field_path);
 
-static inline void format_object(char **buf_ch, bool extended,
-               const char *prefix, const struct bt_object *obj)
+static inline void format_object(char **buf_ch, const char *prefix,
+               const struct bt_object *obj)
 {
        BUF_APPEND(", %sref-count=%llu", prefix, obj->ref_count);
 }
@@ -125,8 +119,8 @@ static inline void format_uuid(char **buf_ch, bt_uuid uuid)
        BUF_APPEND("\"" BT_UUID_FMT "\"", BT_UUID_FMT_VALUES(uuid));
 }
 
-static inline void format_object_pool(char **buf_ch, bool extended,
-               const char *prefix, const struct bt_object_pool *pool)
+static inline void format_object_pool(char **buf_ch, const char *prefix,
+               const struct bt_object_pool *pool)
 {
        BUF_APPEND(", %ssize=%zu", PRFIELD(pool->size));
 
@@ -135,8 +129,7 @@ static inline void format_object_pool(char **buf_ch, bool extended,
        }
 }
 
-static inline void format_integer_field_class(char **buf_ch,
-               bool extended, const char *prefix,
+static inline void format_integer_field_class(char **buf_ch, const char *prefix,
                const struct bt_field_class *field_class)
 {
        const struct bt_field_class_integer *int_fc =
@@ -147,8 +140,7 @@ static inline void format_integer_field_class(char **buf_ch,
                PRFIELD(bt_common_field_class_integer_preferred_display_base_string(int_fc->base)));
 }
 
-static inline void format_array_field_class(char **buf_ch,
-               bool extended, const char *prefix,
+static inline void format_array_field_class(char **buf_ch, const char *prefix,
                const struct bt_field_class *field_class)
 {
        const struct bt_field_class_array *array_fc =
@@ -187,7 +179,7 @@ static inline void format_field_class(char **buf_ch, bool extended,
        case BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER:
        case BT_FIELD_CLASS_TYPE_SIGNED_INTEGER:
        {
-               format_integer_field_class(buf_ch, extended, prefix, field_class);
+               format_integer_field_class(buf_ch, prefix, field_class);
                break;
        }
        case BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION:
@@ -196,7 +188,7 @@ static inline void format_field_class(char **buf_ch, bool extended,
                const struct bt_field_class_enumeration *enum_fc =
                        (const void *) field_class;
 
-               format_integer_field_class(buf_ch, extended, prefix, field_class);
+               format_integer_field_class(buf_ch, prefix, field_class);
                BUF_APPEND(", %smapping-count=%u",
                        PRFIELD(enum_fc->mappings->len));
                break;
@@ -218,7 +210,7 @@ static inline void format_field_class(char **buf_ch, bool extended,
                const struct bt_field_class_array_static *array_fc =
                        (const void *) field_class;
 
-               format_array_field_class(buf_ch, extended, prefix, field_class);
+               format_array_field_class(buf_ch, prefix, field_class);
                BUF_APPEND(", %slength=%" PRIu64, PRFIELD(array_fc->length));
                break;
        }
@@ -228,7 +220,7 @@ static inline void format_field_class(char **buf_ch, bool extended,
                const struct bt_field_class_array_dynamic *array_fc =
                        (const void *) field_class;
 
-               format_array_field_class(buf_ch, extended, prefix, field_class);
+               format_array_field_class(buf_ch, prefix, field_class);
 
                if (array_fc->length_fc) {
                        SET_TMP_PREFIX("length-fc-");
@@ -505,8 +497,8 @@ static inline void format_trace(char **buf_ch, bool extended,
 {
        char tmp_prefix[TMP_PREFIX_LEN];
 
-       if (trace->name.value) {
-               BUF_APPEND(", %sname=\"%s\"", PRFIELD(trace->name.value));
+       if (trace->name) {
+               BUF_APPEND(", %sname=\"%s\"", PRFIELD(trace->name));
        }
 
        if (!extended) {
@@ -542,9 +534,9 @@ static inline void format_stream_class(char **buf_ch, bool extended,
 
        BUF_APPEND(", %sid=%" PRIu64, PRFIELD(stream_class->id));
 
-       if (stream_class->name.value) {
+       if (stream_class->name) {
                BUF_APPEND(", %sname=\"%s\"",
-                       PRFIELD(stream_class->name.value));
+                       PRFIELD(stream_class->name));
        }
 
        if (!extended) {
@@ -588,7 +580,7 @@ static inline void format_stream_class(char **buf_ch, bool extended,
        SET_TMP_PREFIX("trace-class-");
        format_trace_class(buf_ch, false, tmp_prefix, trace_class);
        SET_TMP_PREFIX("pcf-pool-");
-       format_object_pool(buf_ch, extended, tmp_prefix,
+       format_object_pool(buf_ch, tmp_prefix,
                &stream_class->packet_context_field_pool);
 }
 
@@ -601,9 +593,9 @@ static inline void format_event_class(char **buf_ch, bool extended,
 
        BUF_APPEND(", %sid=%" PRIu64, PRFIELD(event_class->id));
 
-       if (event_class->name.value) {
+       if (event_class->name) {
                BUF_APPEND(", %sname=\"%s\"",
-                       PRFIELD(event_class->name.value));
+                       PRFIELD(event_class->name));
        }
 
        if (!extended) {
@@ -618,9 +610,9 @@ static inline void format_event_class(char **buf_ch, bool extended,
                                (int) event_class->log_level.value)));
        }
 
-       if (event_class->emf_uri.value) {
+       if (event_class->emf_uri) {
                BUF_APPEND(", %semf-uri=\"%s\"",
-                       PRFIELD(event_class->emf_uri.value));
+                       PRFIELD(event_class->emf_uri));
        }
 
        BUF_APPEND(", %sspecific-context-fc-addr=%p, %spayload-fc-addr=%p",
@@ -644,8 +636,7 @@ static inline void format_event_class(char **buf_ch, bool extended,
        SET_TMP_PREFIX("trace-class-");
        format_trace_class(buf_ch, false, tmp_prefix, trace_class);
        SET_TMP_PREFIX("event-pool-");
-       format_object_pool(buf_ch, extended, tmp_prefix,
-               &event_class->event_pool);
+       format_object_pool(buf_ch, tmp_prefix, &event_class->event_pool);
 }
 
 static inline void format_stream(char **buf_ch, bool extended,
@@ -658,8 +649,8 @@ static inline void format_stream(char **buf_ch, bool extended,
 
        BUF_APPEND(", %sid=%" PRIu64, PRFIELD(stream->id));
 
-       if (stream->name.value) {
-               BUF_APPEND(", %sname=\"%s\"", PRFIELD(stream->name.value));
+       if (stream->name) {
+               BUF_APPEND(", %sname=\"%s\"", PRFIELD(stream->name));
        }
 
        if (!extended) {
@@ -688,7 +679,7 @@ static inline void format_stream(char **buf_ch, bool extended,
        }
 
        SET_TMP_PREFIX("packet-pool-");
-       format_object_pool(buf_ch, extended, tmp_prefix, &stream->packet_pool);
+       format_object_pool(buf_ch, tmp_prefix, &stream->packet_pool);
 }
 
 static inline void format_packet(char **buf_ch, bool extended,
@@ -786,8 +777,8 @@ static inline void format_clock_class(char **buf_ch, bool extended,
 {
        char tmp_prefix[TMP_PREFIX_LEN];
 
-       if (clock_class->name.value) {
-               BUF_APPEND(", %sname=\"%s\"", PRFIELD(clock_class->name.value));
+       if (clock_class->name) {
+               BUF_APPEND(", %sname=\"%s\"", PRFIELD(clock_class->name));
        }
 
        BUF_APPEND(", %sfreq=%" PRIu64, PRFIELD(clock_class->frequency));
@@ -796,9 +787,9 @@ static inline void format_clock_class(char **buf_ch, bool extended,
                return;
        }
 
-       if (clock_class->description.value) {
+       if (clock_class->description) {
                BUF_APPEND(", %spartial-descr=\"%.32s\"",
-                       PRFIELD(clock_class->description.value));
+                       PRFIELD(clock_class->description));
        }
 
        if (clock_class->uuid.value) {
@@ -816,8 +807,7 @@ static inline void format_clock_class(char **buf_ch, bool extended,
                PRFIELD(clock_class->base_offset.value_ns));
 
        SET_TMP_PREFIX("cs-pool-");
-       format_object_pool(buf_ch, extended, tmp_prefix,
-               &clock_class->cs_pool);
+       format_object_pool(buf_ch, tmp_prefix, &clock_class->cs_pool);
 }
 
 static inline void format_clock_snapshot(char **buf_ch, bool extended,
@@ -843,8 +833,8 @@ static inline void format_clock_snapshot(char **buf_ch, bool extended,
        }
 }
 
-static inline void format_interrupter(char **buf_ch, bool extended,
-               const char *prefix, const struct bt_interrupter *intr)
+static inline void format_interrupter(char **buf_ch, const char *prefix,
+               const struct bt_interrupter *intr)
 {
        BUF_APPEND(", %sis-set=%d", PRFIELD(intr->is_set));
 }
@@ -932,7 +922,7 @@ static inline void format_message(char **buf_ch, bool extended,
        char tmp_prefix[TMP_PREFIX_LEN];
 
        BUF_APPEND(", %stype=%s",
-               PRFIELD(bt_message_type_string(msg->type)));
+               PRFIELD(bt_common_message_type_string(msg->type)));
 
        if (!extended) {
                return;
@@ -1057,7 +1047,7 @@ static inline void format_component_class(char **buf_ch, bool extended,
        char tmp_prefix[TMP_PREFIX_LEN];
 
        BUF_APPEND(", %stype=%s, %sname=\"%s\"",
-               PRFIELD(bt_component_class_type_string(comp_class->type)),
+               PRFIELD(bt_common_component_class_type_string(comp_class->type)),
                PRFIELD_GSTRING(comp_class->name));
 
        if (comp_class->description) {
@@ -1173,21 +1163,11 @@ static inline void format_graph(char **buf_ch, bool extended,
        }
 
        SET_TMP_PREFIX("en-pool-");
-       format_object_pool(buf_ch, extended, tmp_prefix,
-               &graph->event_msg_pool);
+       format_object_pool(buf_ch, tmp_prefix, &graph->event_msg_pool);
        SET_TMP_PREFIX("pbn-pool-");
-       format_object_pool(buf_ch, extended, tmp_prefix,
-               &graph->packet_begin_msg_pool);
+       format_object_pool(buf_ch, tmp_prefix, &graph->packet_begin_msg_pool);
        SET_TMP_PREFIX("pen-pool-");
-       format_object_pool(buf_ch, extended, tmp_prefix,
-               &graph->packet_end_msg_pool);
-}
-
-static inline void format_message_iterator_class(char **buf_ch,
-               bool extended, const char *prefix,
-               const struct bt_message_iterator_class *iterator_class)
-{
-       /* Empty, the address is automatically printed. */
+       format_object_pool(buf_ch, tmp_prefix, &graph->packet_end_msg_pool);
 }
 
 static inline void format_message_iterator(char **buf_ch,
@@ -1335,15 +1315,17 @@ static inline void format_error_cause(char **buf_ch, bool extended,
        if (comp_class_id) {
                BUF_APPEND(", %scomp-cls-type=%s, %scomp-cls-name=\"%s\", "
                        "%splugin-name=\"%s\"",
-                       PRFIELD(bt_component_class_type_string(
+                       PRFIELD(bt_common_component_class_type_string(
                                comp_class_id->type)),
                        PRFIELD_GSTRING(comp_class_id->name),
                        PRFIELD_GSTRING(comp_class_id->plugin_name));
        }
 }
 
-static inline void handle_conversion_specifier_bt(void *priv_data,
-               char **buf_ch, size_t avail_size,
+static inline void handle_conversion_specifier_bt(
+               void *priv_data __attribute__((unused)),
+               char **buf_ch,
+               size_t avail_size __attribute__((unused)),
                const char **out_fmt_ch, va_list *args)
 {
        const char *fmt_ch = *out_fmt_ch;
@@ -1440,7 +1422,7 @@ static inline void handle_conversion_specifier_bt(void *priv_data,
                format_message(buf_ch, extended, prefix, obj);
                break;
        case 'I':
-               format_message_iterator_class(buf_ch, extended, prefix, obj);
+               /* Empty, the address is automatically printed. */
                break;
        case 'i':
                format_message_iterator(buf_ch, extended, prefix, obj);
@@ -1464,13 +1446,13 @@ static inline void handle_conversion_specifier_bt(void *priv_data,
                format_graph(buf_ch, extended, prefix, obj);
                break;
        case 'z':
-               format_interrupter(buf_ch, extended, prefix, obj);
+               format_interrupter(buf_ch, prefix, obj);
                break;
        case 'o':
-               format_object_pool(buf_ch, extended, prefix, obj);
+               format_object_pool(buf_ch, prefix, obj);
                break;
        case 'O':
-               format_object(buf_ch, extended, prefix, obj);
+               format_object(buf_ch, prefix, obj);
                break;
        case 'r':
                format_error_cause(buf_ch, extended, prefix, obj);
@@ -1484,19 +1466,47 @@ update_fmt:
        *out_fmt_ch = fmt_ch;
 }
 
-void bt_lib_log(const char *func, const char *file, unsigned line,
+/*
+ * This function would normally not be BT_EXPORTed, but it is used by the
+ * Python plugin provider, which is conceptually part of libbabeltrace2, but
+ * implemented as a separate shared object, for modularity.  It is therefore
+ * exposed, but not part of the public ABI.
+ */
+BT_EXPORT
+void bt_lib_log_v(const char *file, const char *func, unsigned line,
+               int lvl, const char *tag, const char *fmt, va_list *args)
+{
+       BT_ASSERT(fmt);
+       bt_common_custom_vsnprintf(lib_logging_buf, LIB_LOGGING_BUF_SIZE, '!',
+               handle_conversion_specifier_bt, NULL, fmt, args);
+       bt_log_write(file, func, line, lvl, tag, lib_logging_buf);
+}
+
+/*
+ * This function would normally not be BT_EXPORTed, but it is used by the
+ * Python plugin provider, which is conceptually part of libbabeltrace2, but
+ * implemented as a separate shared object, for modularity.  It is therefore
+ * exposed, but not part of the public ABI.
+ */
+BT_EXPORT
+void bt_lib_log(const char *file, const char *func, unsigned line,
                int lvl, const char *tag, const char *fmt, ...)
 {
        va_list args;
 
        BT_ASSERT(fmt);
        va_start(args, fmt);
-       bt_common_custom_vsnprintf(lib_logging_buf, LIB_LOGGING_BUF_SIZE, '!',
-               handle_conversion_specifier_bt, NULL, fmt, &args);
+       bt_lib_log_v(file, func, line, lvl, tag, fmt, &args);
        va_end(args);
-       _bt_log_write_d(func, file, line, lvl, tag, "%s", lib_logging_buf);
 }
 
+/*
+ * This function would normally not be BT_EXPORTed, but it is used by the
+ * Python plugin provider, which is conceptually part of libbabeltrace2, but
+ * implemented as a separate shared object, for modularity.  It is therefore
+ * exposed, but not part of the ABI.
+ */
+BT_EXPORT
 void bt_lib_maybe_log_and_append_cause(const char *func, const char *file,
                unsigned line, int lvl, const char *tag,
                const char *fmt, ...)
@@ -1512,8 +1522,7 @@ void bt_lib_maybe_log_and_append_cause(const char *func, const char *file,
 
        /* Log conditionally, but always append the error cause */
        if (BT_LOG_ON(lvl)) {
-               _bt_log_write_d(func, file, line, lvl, tag, "%s",
-                       lib_logging_buf);
+               bt_log_write(file, func, line, lvl, tag, lib_logging_buf);
        }
 
        status = bt_current_thread_error_append_cause_from_unknown(
This page took 0.029282 seconds and 4 git commands to generate.