lib: make packets and packet messages optional, disabled by default
[babeltrace.git] / src / lib / lib-logging.c
index 4c69d62f5b034cf778f0c0fb9bb91a6c6bb51310..c9c8249b39af6ed07d5f7321495e6c56e6f98e8c 100644 (file)
@@ -32,6 +32,7 @@
 #include <wchar.h>
 #include <glib.h>
 #include "common/common.h"
+#include "common/uuid.h"
 #include <babeltrace2/trace-ir/event-const.h>
 #include <babeltrace2/trace-ir/packet-const.h>
 #include <babeltrace2/trace-ir/stream-const.h>
@@ -56,7 +57,6 @@
 #include "graph/message/message.h"
 #include "graph/message/message-iterator-inactivity.h"
 #include "graph/message/packet.h"
-#include "graph/message/stream-activity.h"
 #include "graph/message/stream.h"
 #include "graph/port.h"
 #include "plugin/plugin.h"
@@ -135,23 +135,7 @@ static inline void format_object(char **buf_ch, bool extended,
 
 static inline void format_uuid(char **buf_ch, bt_uuid uuid)
 {
-       BUF_APPEND("\"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\"",
-               (unsigned int) uuid[0],
-               (unsigned int) uuid[1],
-               (unsigned int) uuid[2],
-               (unsigned int) uuid[3],
-               (unsigned int) uuid[4],
-               (unsigned int) uuid[5],
-               (unsigned int) uuid[6],
-               (unsigned int) uuid[7],
-               (unsigned int) uuid[8],
-               (unsigned int) uuid[9],
-               (unsigned int) uuid[10],
-               (unsigned int) uuid[11],
-               (unsigned int) uuid[12],
-               (unsigned int) uuid[13],
-               (unsigned int) uuid[14],
-               (unsigned int) uuid[15]);
+       BUF_APPEND("\"" BT_UUID_FMT "\"", BT_UUID_FMT_VALUES(uuid));
 }
 
 static inline void format_object_pool(char **buf_ch, bool extended,
@@ -534,14 +518,16 @@ static inline void format_stream_class(char **buf_ch, bool extended,
        }
 
        BUF_APPEND(", %sassigns-auto-ec-id=%d, %sassigns-auto-stream-id=%d, "
-               "%spackets-have-default-beginning-cs=%d, "
-               "%spackets-have-default-end-cs=%d, "
+               "%ssupports-packets=%d, "
+               "%spackets-have-begin-default-cs=%d, "
+               "%spackets-have-end-default-cs=%d, "
                "%ssupports-discarded-events=%d, "
                "%sdiscarded-events-have-default-cs=%d, "
                "%ssupports-discarded-packets=%d, "
                "%sdiscarded-packets-have-default-cs=%d",
                PRFIELD(stream_class->assigns_automatic_event_class_id),
                PRFIELD(stream_class->assigns_automatic_stream_id),
+               PRFIELD(stream_class->supports_packets),
                PRFIELD(stream_class->packets_have_beginning_default_clock_snapshot),
                PRFIELD(stream_class->packets_have_end_default_clock_snapshot),
                PRFIELD(stream_class->supports_discarded_events),
@@ -690,8 +676,6 @@ static inline void format_packet(char **buf_ch, bool extended,
 static inline void format_event(char **buf_ch, bool extended,
                const char *prefix, const struct bt_event *event)
 {
-       const struct bt_packet *packet;
-       const struct bt_stream *stream;
        const struct bt_trace_class *trace_class;
        const struct bt_stream_class *stream_class;
        char tmp_prefix[TMP_PREFIX_LEN];
@@ -734,22 +718,17 @@ static inline void format_event(char **buf_ch, bool extended,
                }
        }
 
-       packet = bt_event_borrow_packet_const(event);
-       if (!packet) {
-               return;
+       if (event->stream) {
+               BUF_APPEND(", %sstream-addr=%p", PRFIELD(event->stream));
+               SET_TMP_PREFIX("stream-");
+               format_stream(buf_ch, false, tmp_prefix, event->stream);
        }
 
-       BUF_APPEND(", %spacket-addr=%p", PRFIELD(packet));
-       SET_TMP_PREFIX("packet-");
-       format_packet(buf_ch, false, tmp_prefix, packet);
-       stream = bt_packet_borrow_stream_const(packet);
-       if (!stream) {
-               return;
+       if (event->packet) {
+               BUF_APPEND(", %spacket-addr=%p", PRFIELD(event->packet));
+               SET_TMP_PREFIX("packet-");
+               format_packet(buf_ch, false, tmp_prefix, event->packet);
        }
-
-       BUF_APPEND(", %sstream-addr=%p", PRFIELD(stream));
-       SET_TMP_PREFIX("stream-");
-       format_stream(buf_ch, false, tmp_prefix, stream);
 }
 
 static inline void format_clock_class(char **buf_ch, bool extended,
@@ -925,28 +904,14 @@ static inline void format_message(char **buf_ch, bool extended,
                                msg_stream->stream);
                }
 
-               break;
-       }
-       case BT_MESSAGE_TYPE_STREAM_ACTIVITY_BEGINNING:
-       case BT_MESSAGE_TYPE_STREAM_ACTIVITY_END:
-       {
-               const struct bt_message_stream_activity *msg_stream_activity =
-                       (const void *) msg;
-
-               if (msg_stream_activity->stream) {
-                       SET_TMP_PREFIX("stream-");
-                       format_stream(buf_ch, true, tmp_prefix,
-                               msg_stream_activity->stream);
-               }
-
                BUF_APPEND(", %sdefault-cs-state=%s",
-                       PRFIELD(bt_message_stream_activity_clock_snapshot_state_string(
-                               msg_stream_activity->default_cs_state)));
+                       PRFIELD(bt_message_stream_clock_snapshot_state_string(
+                               msg_stream->default_cs_state)));
 
-               if (msg_stream_activity->default_cs) {
+               if (msg_stream->default_cs_state == BT_MESSAGE_STREAM_CLOCK_SNAPSHOT_STATE_KNOWN) {
                        SET_TMP_PREFIX("default-cs-");
                        format_clock_snapshot(buf_ch, true, tmp_prefix,
-                               msg_stream_activity->default_cs);
+                               msg_stream->default_cs);
                }
 
                break;
@@ -983,13 +948,13 @@ static inline void format_message(char **buf_ch, bool extended,
                }
 
                if (msg_disc_items->default_begin_cs) {
-                       SET_TMP_PREFIX("default-begin-cs-");
+                       SET_TMP_PREFIX("begin-default-cs-");
                        format_clock_snapshot(buf_ch, true, tmp_prefix,
                                msg_disc_items->default_begin_cs);
                }
 
                if (msg_disc_items->default_end_cs) {
-                       SET_TMP_PREFIX("default-end-cs-");
+                       SET_TMP_PREFIX("end-default-cs-");
                        format_clock_snapshot(buf_ch, true, tmp_prefix,
                                msg_disc_items->default_end_cs);
                }
This page took 0.025379 seconds and 4 git commands to generate.