* SOFTWARE.
*/
-#define BT_LOG_TAG "PLUGIN-CTF-FS-SINK-STREAM"
-#include "logging.h"
+#define BT_COMP_LOG_SELF_COMP (stream->trace->fs_sink->self_comp)
+#define BT_LOG_OUTPUT_LEVEL (stream->log_level)
+#define BT_LOG_TAG "PLUGIN/SINK.CTF.FS/STREAM"
+#include "plugins/comp-logging.h"
#include <babeltrace2/babeltrace.h>
#include <stdio.h>
#include "ctfser/ctfser.h"
#include "compat/endian.h"
+#include "fs-sink.h"
#include "fs-sink-trace.h"
#include "fs-sink-stream.h"
#include "translate-trace-ir-to-ctf-ir.h"
goto end;
}
+ stream->log_level = trace->log_level;
stream->trace = trace;
stream->ir_stream = ir_stream;
stream->packet_state.beginning_cs = UINT64_C(-1);
stream->prev_packet_state.end_cs = UINT64_C(-1);
stream->prev_packet_state.discarded_events_counter = UINT64_C(-1);
stream->prev_packet_state.seq_num = UINT64_C(-1);
- ret = try_translate_stream_class_trace_ir_to_ctf_ir(trace->tc,
- bt_stream_borrow_class_const(ir_stream), &stream->sc);
+ ret = try_translate_stream_class_trace_ir_to_ctf_ir(trace->fs_sink,
+ trace->trace, bt_stream_borrow_class_const(ir_stream),
+ &stream->sc);
if (ret) {
goto error;
}
set_stream_file_name(stream);
g_string_append_printf(path, "/%s", stream->file_name->str);
- ret = bt_ctfser_init(&stream->ctfser, path->str);
+ ret = bt_ctfser_init(&stream->ctfser, path->str,
+ stream->log_level);
if (ret) {
goto error;
}
if (fc->is_signed) {
ret = bt_ctfser_write_signed_int(&stream->ctfser,
- bt_field_signed_integer_get_value(field),
+ bt_field_integer_signed_get_value(field),
fc->base.base.alignment, fc->base.size, BYTE_ORDER);
} else {
ret = bt_ctfser_write_unsigned_int(&stream->ctfser,
- bt_field_unsigned_integer_get_value(field),
+ bt_field_integer_unsigned_get_value(field),
fc->base.base.alignment, fc->base.size, BYTE_ORDER);
}
bt_field_array_borrow_element_field_by_index_const(
field, i);
ret = write_field(stream, fc->elem_fc, elem_field);
- if (unlikely(ret)) {
+ if (G_UNLIKELY(ret)) {
goto end;
}
}
if (fc->length_is_before) {
ret = bt_ctfser_write_unsigned_int(&stream->ctfser,
bt_field_array_get_length(field), 8, 32, BYTE_ORDER);
- if (unlikely(ret)) {
+ if (G_UNLIKELY(ret)) {
goto end;
}
}
int ret = 0;
uint64_t i;
- if (likely(align_struct)) {
+ if (G_LIKELY(align_struct)) {
ret = bt_ctfser_align_offset_in_current_packet(&stream->ctfser,
fc->base.alignment);
- if (unlikely(ret)) {
+ if (G_UNLIKELY(ret)) {
goto end;
}
}
fc, i)->fc;
ret = write_field(stream, member_fc, memb_field);
- if (unlikely(ret)) {
+ if (G_UNLIKELY(ret)) {
goto end;
}
}
if (fc->tag_is_before) {
ret = bt_ctfser_write_unsigned_int(&stream->ctfser,
opt_index, 8, 16, BYTE_ORDER);
- if (unlikely(ret)) {
+ if (G_UNLIKELY(ret)) {
goto end;
}
}
/* Event class ID */
ret = bt_ctfser_write_byte_aligned_unsigned_int(&stream->ctfser,
bt_event_class_get_id(ec->ir_ec), 8, 64, BYTE_ORDER);
- if (unlikely(ret)) {
+ if (G_UNLIKELY(ret)) {
goto end;
}
BT_ASSERT(cs);
ret = bt_ctfser_write_byte_aligned_unsigned_int(&stream->ctfser,
bt_clock_snapshot_get_value(cs), 8, 64, BYTE_ORDER);
- if (unlikely(ret)) {
+ if (G_UNLIKELY(ret)) {
goto end;
}
}
/* Header */
ret = write_event_header(stream, cs, ec);
- if (unlikely(ret)) {
+ if (G_UNLIKELY(ret)) {
goto end;
}
ret = write_struct_field(stream,
(void *) stream->sc->event_common_context_fc,
field, true);
- if (unlikely(ret)) {
+ if (G_UNLIKELY(ret)) {
goto end;
}
}
BT_ASSERT(field);
ret = write_struct_field(stream, (void *) ec->spec_context_fc,
field, true);
- if (unlikely(ret)) {
+ if (G_UNLIKELY(ret)) {
goto end;
}
}
BT_ASSERT(field);
ret = write_struct_field(stream, (void *) ec->payload_fc,
field, true);
- if (unlikely(ret)) {
+ if (G_UNLIKELY(ret)) {
goto end;
}
}
/* Other members */
if (stream->sc->packet_context_fc) {
- const bt_field *packet_context_field =
- bt_packet_borrow_context_field_const(
- stream->packet_state.packet);
+ const bt_field *packet_context_field;
+ BT_ASSERT(stream->packet_state.packet);
+ packet_context_field = bt_packet_borrow_context_field_const(
+ stream->packet_state.packet);
BT_ASSERT(packet_context_field);
ret = write_struct_field(stream,
(void *) stream->sc->packet_context_fc,
ret = bt_ctfser_write_byte_aligned_unsigned_int(&stream->ctfser,
UINT64_C(0xc1fc1fc1), 8, 32, BYTE_ORDER);
if (ret) {
- BT_LOGE("Error writing packet header magic: stream-file-name=%s",
+ BT_COMP_LOGE("Error writing packet header magic: stream-file-name=%s",
stream->file_name->str);
goto end;
}
/* Packet header: UUID */
- for (i = 0; i < BABELTRACE_UUID_LEN; i++) {
+ for (i = 0; i < BT_UUID_LEN; i++) {
ret = bt_ctfser_write_byte_aligned_unsigned_int(&stream->ctfser,
- (uint64_t) stream->sc->tc->uuid[i], 8, 8, BYTE_ORDER);
+ (uint64_t) stream->sc->trace->uuid[i], 8, 8, BYTE_ORDER);
if (ret) {
- BT_LOGE("Error writing packet header UUID: stream-file-name=%s",
+ BT_COMP_LOGE("Error writing packet header UUID: stream-file-name=%s",
stream->file_name->str);
goto end;
}
ret = bt_ctfser_write_byte_aligned_unsigned_int(&stream->ctfser,
bt_stream_class_get_id(stream->sc->ir_sc), 8, 64, BYTE_ORDER);
if (ret) {
- BT_LOGE("Error writing packet header stream class id: "
+ BT_COMP_LOGE("Error writing packet header stream class id: "
"stream-file-name=%s, stream-class-id=%"PRIu64,
stream->file_name->str,
bt_stream_class_get_id(stream->sc->ir_sc));
ret = bt_ctfser_write_byte_aligned_unsigned_int(&stream->ctfser,
bt_stream_get_id(stream->ir_stream), 8, 64, BYTE_ORDER);
if (ret) {
- BT_LOGE("Error writing packet header stream id: "
+ BT_COMP_LOGE("Error writing packet header stream id: "
"stream-file-name=%s, stream-id=%"PRIu64,
stream->file_name->str,
bt_stream_get_id(stream->ir_stream));