sink.ctf.fs: use BT_COMP_LOG*() instead of BT_LOG*()
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Tue, 18 Jun 2019 19:20:23 +0000 (15:20 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 20 Jun 2019 18:01:16 +0000 (14:01 -0400)
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I1b337c6fb7c38def67cd5418c96df2df6faa020e
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1502
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
src/plugins/ctf/fs-sink/fs-sink-stream.c
src/plugins/ctf/fs-sink/fs-sink-trace.c
src/plugins/ctf/fs-sink/fs-sink.c
src/plugins/ctf/fs-sink/fs-sink.h
src/plugins/ctf/fs-sink/translate-trace-ir-to-ctf-ir.c
src/plugins/ctf/fs-sink/translate-trace-ir-to-ctf-ir.h

index a8fd554733b654f1ebf5cd11ff3079245e73a38b..921dafa3020328c9bfdb418418603ec2cb59f6ef 100644 (file)
  * SOFTWARE.
  */
 
+#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 "logging/log.h"
+#include "plugins/comp-logging.h"
 
 #include <babeltrace2/babeltrace.h>
 #include <stdio.h>
@@ -32,6 +33,7 @@
 #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"
@@ -162,9 +164,9 @@ struct fs_sink_stream *fs_sink_stream_create(struct fs_sink_trace *trace,
        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,
-               stream->log_level);
+       ret = try_translate_stream_class_trace_ir_to_ctf_ir(trace->fs_sink,
+               trace->tc, bt_stream_borrow_class_const(ir_stream),
+               &stream->sc);
        if (ret) {
                goto error;
        }
@@ -559,7 +561,7 @@ int fs_sink_stream_open_packet(struct fs_sink_stream *stream,
        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;
        }
@@ -569,7 +571,7 @@ int fs_sink_stream_open_packet(struct fs_sink_stream *stream,
                ret = bt_ctfser_write_byte_aligned_unsigned_int(&stream->ctfser,
                        (uint64_t) stream->sc->tc->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;
                }
@@ -579,7 +581,7 @@ int fs_sink_stream_open_packet(struct fs_sink_stream *stream,
        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));
@@ -590,7 +592,7 @@ int fs_sink_stream_open_packet(struct fs_sink_stream *stream,
        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));
index e235820fdad2526801609c315d38c83f32e0f94d..c45397554e3672a3cb258013740ac547d7da7c33 100644 (file)
  * SOFTWARE.
  */
 
+#define BT_COMP_LOG_SELF_COMP (trace->fs_sink->self_comp)
 #define BT_LOG_OUTPUT_LEVEL (trace->log_level)
 #define BT_LOG_TAG "PLUGIN/SINK.CTF.FS/TRACE"
-#include "logging/log.h"
+#include "plugins/comp-logging.h"
 
 #include <babeltrace2/babeltrace.h>
 #include <stdio.h>
@@ -151,7 +152,7 @@ int lttng_validate_datetime(const struct fs_sink_trace *trace,
         * the format.
         */
        if (!g_time_val_from_iso8601(datetime, &tv)) {
-               BT_LOGI("Couldn't parse datetime as ISO 8601: date=\"%s\"", datetime);
+               BT_COMP_LOGI("Couldn't parse datetime as ISO 8601: date=\"%s\"", datetime);
                goto end;
        }
 
@@ -170,7 +171,7 @@ int append_lttng_trace_path_ust_uid(const struct fs_sink_trace *trace,
 
        v = bt_trace_class_borrow_environment_entry_value_by_name_const(tc, "tracer_buffering_id");
        if (!v || !bt_value_is_signed_integer(v)) {
-               BT_LOGI_STR("Couldn't get environment value: name=\"tracer_buffering_id\"");
+               BT_COMP_LOGI_STR("Couldn't get environment value: name=\"tracer_buffering_id\"");
                goto error;
        }
 
@@ -179,7 +180,7 @@ int append_lttng_trace_path_ust_uid(const struct fs_sink_trace *trace,
 
        v = bt_trace_class_borrow_environment_entry_value_by_name_const(tc, "isa_length");
        if (!v || !bt_value_is_signed_integer(v)) {
-               BT_LOGI_STR("Couldn't get environment value: name=\"isa_length\"");
+               BT_COMP_LOGI_STR("Couldn't get environment value: name=\"isa_length\"");
                goto error;
        }
 
@@ -206,7 +207,7 @@ int append_lttng_trace_path_ust_pid(const struct fs_sink_trace *trace,
 
        v = bt_trace_class_borrow_environment_entry_value_by_name_const(tc, "procname");
        if (!v || !bt_value_is_string(v)) {
-               BT_LOGI_STR("Couldn't get environment value: name=\"procname\"");
+               BT_COMP_LOGI_STR("Couldn't get environment value: name=\"procname\"");
                goto error;
        }
 
@@ -214,7 +215,7 @@ int append_lttng_trace_path_ust_pid(const struct fs_sink_trace *trace,
 
        v = bt_trace_class_borrow_environment_entry_value_by_name_const(tc, "vpid");
        if (!v || !bt_value_is_signed_integer(v)) {
-               BT_LOGI_STR("Couldn't get environment value: name=\"vpid\"");
+               BT_COMP_LOGI_STR("Couldn't get environment value: name=\"vpid\"");
                goto error;
        }
 
@@ -222,7 +223,7 @@ int append_lttng_trace_path_ust_pid(const struct fs_sink_trace *trace,
 
        v = bt_trace_class_borrow_environment_entry_value_by_name_const(tc, "vpid_datetime");
        if (!v || !bt_value_is_string(v)) {
-               BT_LOGI_STR("Couldn't get environment value: name=\"vpid_datetime\"");
+               BT_COMP_LOGI_STR("Couldn't get environment value: name=\"vpid_datetime\"");
                goto error;
        }
 
@@ -266,7 +267,7 @@ GString *make_lttng_trace_path_rel(const struct fs_sink_trace *trace)
 
        v = bt_trace_class_borrow_environment_entry_value_by_name_const(tc, "tracer_name");
        if (!v || !bt_value_is_string(v)) {
-               BT_LOGI_STR("Couldn't get environment value: name=\"tracer_name\"");
+               BT_COMP_LOGI_STR("Couldn't get environment value: name=\"tracer_name\"");
                goto error;
        }
 
@@ -274,13 +275,13 @@ GString *make_lttng_trace_path_rel(const struct fs_sink_trace *trace)
 
        if (!g_str_equal(tracer_name, "lttng-ust")
                        && !g_str_equal(tracer_name, "lttng-modules")) {
-               BT_LOGI("Unrecognized tracer name: name=\"%s\"", tracer_name);
+               BT_COMP_LOGI("Unrecognized tracer name: name=\"%s\"", tracer_name);
                goto error;
        }
 
        v = bt_trace_class_borrow_environment_entry_value_by_name_const(tc, "tracer_major");
        if (!v || !bt_value_is_signed_integer(v)) {
-               BT_LOGI_STR("Couldn't get environment value: name=\"tracer_major\"");
+               BT_COMP_LOGI_STR("Couldn't get environment value: name=\"tracer_major\"");
                goto error;
        }
 
@@ -288,21 +289,21 @@ GString *make_lttng_trace_path_rel(const struct fs_sink_trace *trace)
 
        v = bt_trace_class_borrow_environment_entry_value_by_name_const(tc, "tracer_minor");
        if (!v || !bt_value_is_signed_integer(v)) {
-               BT_LOGI_STR("Couldn't get environment value: name=\"tracer_minor\"");
+               BT_COMP_LOGI_STR("Couldn't get environment value: name=\"tracer_minor\"");
                goto error;
        }
 
        tracer_minor = bt_value_signed_integer_get(v);
 
        if (!(tracer_major >= 3 || (tracer_major == 2 && tracer_minor >= 11))) {
-               BT_LOGI("Unsupported LTTng version for automatic trace path: major=%" PRId64 ", minor=%" PRId64,
+               BT_COMP_LOGI("Unsupported LTTng version for automatic trace path: major=%" PRId64 ", minor=%" PRId64,
                        tracer_major, tracer_minor);
                goto error;
        }
 
        v = bt_trace_class_borrow_environment_entry_value_by_name_const(tc, "hostname");
        if (!v || !bt_value_is_string(v)) {
-               BT_LOGI_STR("Couldn't get environment value: name=\"tracer_hostname\"");
+               BT_COMP_LOGI_STR("Couldn't get environment value: name=\"tracer_hostname\"");
                goto error;
        }
 
@@ -310,7 +311,7 @@ GString *make_lttng_trace_path_rel(const struct fs_sink_trace *trace)
 
        v = bt_trace_class_borrow_environment_entry_value_by_name_const(tc, "trace_name");
        if (!v || !bt_value_is_string(v)) {
-               BT_LOGI_STR("Couldn't get environment value: name=\"trace_name\"");
+               BT_COMP_LOGI_STR("Couldn't get environment value: name=\"trace_name\"");
                goto error;
        }
 
@@ -318,7 +319,7 @@ GString *make_lttng_trace_path_rel(const struct fs_sink_trace *trace)
 
        v = bt_trace_class_borrow_environment_entry_value_by_name_const(tc, "trace_creation_datetime");
        if (!v || !bt_value_is_string(v)) {
-               BT_LOGI_STR("Couldn't get environment value: name=\"trace_creation_datetime\"");
+               BT_COMP_LOGI_STR("Couldn't get environment value: name=\"trace_creation_datetime\"");
                goto error;
        }
 
@@ -332,7 +333,7 @@ GString *make_lttng_trace_path_rel(const struct fs_sink_trace *trace)
 
        v = bt_trace_class_borrow_environment_entry_value_by_name_const(tc, "domain");
        if (!v || !bt_value_is_string(v)) {
-               BT_LOGI_STR("Couldn't get environment value: name=\"domain\"");
+               BT_COMP_LOGI_STR("Couldn't get environment value: name=\"domain\"");
                goto error;
        }
 
@@ -344,7 +345,7 @@ GString *make_lttng_trace_path_rel(const struct fs_sink_trace *trace)
 
                v = bt_trace_class_borrow_environment_entry_value_by_name_const(tc, "tracer_buffering_scheme");
                if (!v || !bt_value_is_string(v)) {
-                       BT_LOGI_STR("Couldn't get environment value: name=\"tracer_buffering_scheme\"");
+                       BT_COMP_LOGI_STR("Couldn't get environment value: name=\"tracer_buffering_scheme\"");
                        goto error;
                }
 
@@ -361,12 +362,12 @@ GString *make_lttng_trace_path_rel(const struct fs_sink_trace *trace)
                        }
                } else {
                        /* Unknown buffering scheme. */
-                       BT_LOGI("Unknown buffering scheme: tracer_buffering_scheme=\"%s\"", tracer_buffering_scheme);
+                       BT_COMP_LOGI("Unknown buffering scheme: tracer_buffering_scheme=\"%s\"", tracer_buffering_scheme);
                        goto error;
                }
        } else if (!g_str_equal(domain, "kernel")) {
                /* Unknown domain. */
-               BT_LOGI("Unknown domain: domain=\"%s\"", domain);
+               BT_COMP_LOGI("Unknown domain: domain=\"%s\"", domain);
                goto error;
        }
 
@@ -497,7 +498,7 @@ void fs_sink_trace_destroy(struct fs_sink_trace *trace)
        BT_ASSERT(trace->metadata_path);
        fh = fopen(trace->metadata_path->str, "wb");
        if (!fh) {
-               BT_LOGF_ERRNO("In trace destruction listener: "
+               BT_COMP_LOGF_ERRNO("In trace destruction listener: "
                        "cannot open metadata file for writing: ",
                        ": path=\"%s\"", trace->metadata_path->str);
                abort();
@@ -505,7 +506,7 @@ void fs_sink_trace_destroy(struct fs_sink_trace *trace)
 
        len = fwrite(tsdl->str, sizeof(*tsdl->str), tsdl->len, fh);
        if (len != tsdl->len) {
-               BT_LOGF_ERRNO("In trace destruction listener: "
+               BT_COMP_LOGF_ERRNO("In trace destruction listener: "
                        "cannot write metadata file: ",
                        ": path=\"%s\"", trace->metadata_path->str);
                abort();
@@ -532,7 +533,7 @@ end:
                int ret = fclose(fh);
 
                if (ret != 0) {
-                       BT_LOGW_ERRNO("In trace destruction listener: "
+                       BT_COMP_LOGW_ERRNO("In trace destruction listener: "
                                "cannot close metadata file: ",
                                ": path=\"%s\"", trace->metadata_path->str);
                }
@@ -576,8 +577,7 @@ struct fs_sink_trace *fs_sink_trace_create(struct fs_sink_comp *fs_sink,
        trace->ir_trace = ir_trace;
        trace->ir_trace_destruction_listener_id = UINT64_C(-1);
        trace->tc = translate_trace_class_trace_ir_to_ctf_ir(
-               bt_trace_borrow_class_const(ir_trace),
-               fs_sink->log_level);
+               fs_sink, bt_trace_borrow_class_const(ir_trace));
        if (!trace->tc) {
                goto error;
        }
@@ -586,7 +586,7 @@ struct fs_sink_trace *fs_sink_trace_create(struct fs_sink_comp *fs_sink,
        BT_ASSERT(trace->path);
        ret = g_mkdir_with_parents(trace->path->str, 0755);
        if (ret) {
-               BT_LOGE_ERRNO("Cannot create directories for trace directory",
+               BT_COMP_LOGE_ERRNO("Cannot create directories for trace directory",
                        ": path=\"%s\"", trace->path->str);
                goto error;
        }
index f6b5bab41f8d8afb9f59f46f930627aa0e61853d..d630e50d27758cdce2cb8b0a9aafe364056fe72f 100644 (file)
  * SOFTWARE.
  */
 
+#define BT_COMP_LOG_SELF_COMP (fs_sink->self_comp)
 #define BT_LOG_OUTPUT_LEVEL (fs_sink->log_level)
 #define BT_LOG_TAG "PLUGIN/SINK.CTF.FS"
-#include "logging/log.h"
+#include "plugins/comp-logging.h"
 
 #include <babeltrace2/babeltrace.h>
 #include <stdio.h>
@@ -50,7 +51,8 @@ bt_self_component_status ensure_output_dir_exists(
 
        ret = g_mkdir_with_parents(fs_sink->output_dir_path->str, 0755);
        if (ret) {
-               BT_LOGE_ERRNO("Cannot create directories for output directory",
+               BT_COMP_LOGE_ERRNO(
+                       "Cannot create directories for output directory",
                        ": output-dir-path=\"%s\"",
                        fs_sink->output_dir_path->str);
                status = BT_SELF_COMPONENT_STATUS_ERROR;
@@ -70,13 +72,13 @@ bt_self_component_status configure_component(struct fs_sink_comp *fs_sink,
 
        value = bt_value_map_borrow_entry_value_const(params, "path");
        if (!value) {
-               BT_LOGE_STR("Missing mandatory `path` parameter.");
+               BT_COMP_LOGE_STR("Missing mandatory `path` parameter.");
                status = BT_SELF_COMPONENT_STATUS_ERROR;
                goto end;
        }
 
        if (!bt_value_is_string(value)) {
-               BT_LOGE_STR("`path` parameter: expecting a string.");
+               BT_COMP_LOGE_STR("`path` parameter: expecting a string.");
                status = BT_SELF_COMPONENT_STATUS_ERROR;
                goto end;
        }
@@ -87,7 +89,7 @@ bt_self_component_status configure_component(struct fs_sink_comp *fs_sink,
                "assume-single-trace");
        if (value) {
                if (!bt_value_is_bool(value)) {
-                       BT_LOGE_STR("`assume-single-trace` parameter: expecting a boolean.");
+                       BT_COMP_LOGE_STR("`assume-single-trace` parameter: expecting a boolean.");
                        status = BT_SELF_COMPONENT_STATUS_ERROR;
                        goto end;
                }
@@ -99,7 +101,7 @@ bt_self_component_status configure_component(struct fs_sink_comp *fs_sink,
                "ignore-discarded-events");
        if (value) {
                if (!bt_value_is_bool(value)) {
-                       BT_LOGE_STR("`ignore-discarded-events` parameter: expecting a boolean.");
+                       BT_COMP_LOGE_STR("`ignore-discarded-events` parameter: expecting a boolean.");
                        status = BT_SELF_COMPONENT_STATUS_ERROR;
                        goto end;
                }
@@ -112,7 +114,7 @@ bt_self_component_status configure_component(struct fs_sink_comp *fs_sink,
                "ignore-discarded-packets");
        if (value) {
                if (!bt_value_is_bool(value)) {
-                       BT_LOGE_STR("`ignore-discarded-packets` parameter: expecting a boolean.");
+                       BT_COMP_LOGE_STR("`ignore-discarded-packets` parameter: expecting a boolean.");
                        status = BT_SELF_COMPONENT_STATUS_ERROR;
                        goto end;
                }
@@ -125,7 +127,7 @@ bt_self_component_status configure_component(struct fs_sink_comp *fs_sink,
                "quiet");
        if (value) {
                if (!bt_value_is_bool(value)) {
-                       BT_LOGE_STR("`quiet` parameter: expecting a boolean.");
+                       BT_COMP_LOGE_STR("`quiet` parameter: expecting a boolean.");
                        status = BT_SELF_COMPONENT_STATUS_ERROR;
                        goto end;
                }
@@ -176,15 +178,15 @@ bt_self_component_status ctf_fs_sink_init(
 
        fs_sink = g_new0(struct fs_sink_comp, 1);
        if (!fs_sink) {
-               BT_LOG_WRITE_CUR_LVL(BT_LOG_ERROR, log_level, BT_LOG_TAG,
+               BT_COMP_LOG_CUR_LVL(BT_LOG_ERROR, log_level, self_comp,
                        "Failed to allocate one CTF FS sink structure.");
                status = BT_SELF_COMPONENT_STATUS_NOMEM;
                goto end;
        }
 
        fs_sink->log_level = log_level;
+       fs_sink->self_comp = self_comp;
        fs_sink->output_dir_path = g_string_new(NULL);
-       fs_sink->self_comp = self_comp_sink;
        status = configure_component(fs_sink, params);
        if (status != BT_SELF_COMPONENT_STATUS_OK) {
                /* configure_component() logs errors */
@@ -194,7 +196,7 @@ bt_self_component_status ctf_fs_sink_init(
        if (fs_sink->assume_single_trace &&
                        g_file_test(fs_sink->output_dir_path->str,
                                G_FILE_TEST_EXISTS)) {
-               BT_LOGE("Single trace mode, but output path exists: "
+               BT_COMP_LOGE("Single trace mode, but output path exists: "
                        "output-path=\"%s\"", fs_sink->output_dir_path->str);
                status = BT_SELF_COMPONENT_STATUS_ERROR;
                goto end;
@@ -209,7 +211,7 @@ bt_self_component_status ctf_fs_sink_init(
        fs_sink->traces = g_hash_table_new_full(g_direct_hash, g_direct_equal,
                NULL, (GDestroyNotify) fs_sink_trace_destroy);
        if (!fs_sink->traces) {
-               BT_LOGE_STR("Failed to allocate one GHashTable.");
+               BT_COMP_LOGE_STR("Failed to allocate one GHashTable.");
                status = BT_SELF_COMPONENT_STATUS_NOMEM;
                goto end;
        }
@@ -242,7 +244,7 @@ struct fs_sink_stream *borrow_stream(struct fs_sink_comp *fs_sink,
        if (G_UNLIKELY(!trace)) {
                if (fs_sink->assume_single_trace &&
                                g_hash_table_size(fs_sink->traces) > 0) {
-                       BT_LOGE("Single trace mode, but getting more than one trace: "
+                       BT_COMP_LOGE("Single trace mode, but getting more than one trace: "
                                "stream-name=\"%s\"",
                                bt_stream_get_name(ir_stream));
                        goto end;
@@ -284,9 +286,8 @@ bt_self_component_status handle_event_msg(struct fs_sink_comp *fs_sink,
                goto end;
        }
 
-       ret = try_translate_event_class_trace_ir_to_ctf_ir(stream->sc,
-               bt_event_borrow_class_const(ir_event), &ec,
-               fs_sink->log_level);
+       ret = try_translate_event_class_trace_ir_to_ctf_ir(fs_sink,
+               stream->sc, bt_event_borrow_class_const(ir_event), &ec);
        if (ret) {
                status = BT_SELF_COMPONENT_STATUS_ERROR;
                goto end;
@@ -374,7 +375,7 @@ bt_self_component_status handle_packet_beginning_msg(
 
                if (stream->discarded_events_state.beginning_cs !=
                                expected_cs) {
-                       BT_LOGE("Incompatible discarded events message: "
+                       BT_COMP_LOGE("Incompatible discarded events message: "
                                "unexpected beginning time: "
                                "beginning-cs-val=%" PRIu64 ", "
                                "expected-beginning-cs-val=%" PRIu64 ", "
@@ -424,7 +425,7 @@ bt_self_component_status handle_packet_beginning_msg(
                 * this case.
                 */
                if (stream->prev_packet_state.end_cs == UINT64_C(-1)) {
-                       BT_LOGE("Incompatible discarded packets message "
+                       BT_COMP_LOGE("Incompatible discarded packets message "
                                "occuring before the stream's first packet: "
                                "stream-id=%" PRIu64 ", stream-name=\"%s\", "
                                "trace-name=\"%s\", path=\"%s/%s\"",
@@ -439,7 +440,7 @@ bt_self_component_status handle_packet_beginning_msg(
 
                if (stream->discarded_packets_state.beginning_cs !=
                                stream->prev_packet_state.end_cs) {
-                       BT_LOGE("Incompatible discarded packets message: "
+                       BT_COMP_LOGE("Incompatible discarded packets message: "
                                "unexpected beginning time: "
                                "beginning-cs-val=%" PRIu64 ", "
                                "expected-beginning-cs-val=%" PRIu64 ", "
@@ -460,7 +461,7 @@ bt_self_component_status handle_packet_beginning_msg(
 
                if (stream->discarded_packets_state.end_cs !=
                                expected_end_cs) {
-                       BT_LOGE("Incompatible discarded packets message: "
+                       BT_COMP_LOGE("Incompatible discarded packets message: "
                                "unexpected end time: "
                                "end-cs-val=%" PRIu64 ", "
                                "expected-end-cs-val=%" PRIu64 ", "
@@ -549,7 +550,7 @@ bt_self_component_status handle_packet_end_msg(
                expected_cs = bt_clock_snapshot_get_value(cs);
 
                if (stream->discarded_events_state.end_cs != expected_cs) {
-                       BT_LOGE("Incompatible discarded events message: "
+                       BT_COMP_LOGE("Incompatible discarded events message: "
                                "unexpected end time: "
                                "end-cs-val=%" PRIu64 ", "
                                "expected-end-cs-val=%" PRIu64 ", "
@@ -606,7 +607,7 @@ bt_self_component_status handle_stream_beginning_msg(
        if (!fs_sink->ignore_discarded_events &&
                        bt_stream_class_discarded_events_have_default_clock_snapshots(ir_sc) &&
                        !packets_have_beginning_end_cs) {
-               BT_LOGE("Unsupported stream: discarded events have "
+               BT_COMP_LOGE("Unsupported stream: discarded events have "
                        "default clock snapshots, but packets have no "
                        "beginning and/or end default clock snapshots: "
                        "stream-addr=%p, "
@@ -626,7 +627,7 @@ bt_self_component_status handle_stream_beginning_msg(
        if (!fs_sink->ignore_discarded_packets &&
                        bt_stream_class_discarded_packets_have_default_clock_snapshots(ir_sc) &&
                        !packets_have_beginning_end_cs) {
-               BT_LOGE("Unsupported stream: discarded packets have "
+               BT_COMP_LOGE("Unsupported stream: discarded packets have "
                        "default clock snapshots, but packets have no "
                        "beginning and/or end default clock snapshots: "
                        "stream-addr=%p, "
@@ -644,7 +645,7 @@ bt_self_component_status handle_stream_beginning_msg(
                goto end;
        }
 
-       BT_LOGI("Created new, empty stream file: "
+       BT_COMP_LOGI("Created new, empty stream file: "
                "stream-id=%" PRIu64 ", stream-name=\"%s\", "
                "trace-name=\"%s\", path=\"%s/%s\"",
                bt_stream_get_id(ir_stream), bt_stream_get_name(ir_stream),
@@ -670,7 +671,7 @@ bt_self_component_status handle_stream_end_msg(struct fs_sink_comp *fs_sink,
                goto end;
        }
 
-       BT_LOGI("Closing stream file: "
+       BT_COMP_LOGI("Closing stream file: "
                "stream-id=%" PRIu64 ", stream-name=\"%s\", "
                "trace-name=\"%s\", path=\"%s/%s\"",
                bt_stream_get_id(ir_stream), bt_stream_get_name(ir_stream),
@@ -706,7 +707,7 @@ bt_self_component_status handle_discarded_events_msg(
        }
 
        if (fs_sink->ignore_discarded_events) {
-               BT_LOGI("Ignoring discarded events message: "
+               BT_COMP_LOGI("Ignoring discarded events message: "
                        "stream-id=%" PRIu64 ", stream-name=\"%s\", "
                        "trace-name=\"%s\", path=\"%s/%s\"",
                        bt_stream_get_id(ir_stream),
@@ -718,7 +719,7 @@ bt_self_component_status handle_discarded_events_msg(
        }
 
        if (stream->discarded_events_state.in_range) {
-               BT_LOGE("Unsupported contiguous discarded events message: "
+               BT_COMP_LOGE("Unsupported contiguous discarded events message: "
                        "stream-id=%" PRIu64 ", stream-name=\"%s\", "
                        "trace-name=\"%s\", path=\"%s/%s\"",
                        bt_stream_get_id(ir_stream),
@@ -740,7 +741,7 @@ bt_self_component_status handle_discarded_events_msg(
         */
        if (stream->packet_state.is_open &&
                        stream->sc->discarded_events_has_ts) {
-               BT_LOGE("Unsupported discarded events message with "
+               BT_COMP_LOGE("Unsupported discarded events message with "
                        "default clock snapshots occuring within a packet: "
                        "stream-id=%" PRIu64 ", stream-name=\"%s\", "
                        "trace-name=\"%s\", path=\"%s/%s\"",
@@ -813,7 +814,7 @@ bt_self_component_status handle_discarded_packets_msg(
        }
 
        if (fs_sink->ignore_discarded_packets) {
-               BT_LOGI("Ignoring discarded packets message: "
+               BT_COMP_LOGI("Ignoring discarded packets message: "
                        "stream-id=%" PRIu64 ", stream-name=\"%s\", "
                        "trace-name=\"%s\", path=\"%s/%s\"",
                        bt_stream_get_id(ir_stream),
@@ -825,7 +826,7 @@ bt_self_component_status handle_discarded_packets_msg(
        }
 
        if (stream->discarded_packets_state.in_range) {
-               BT_LOGE("Unsupported contiguous discarded packets message: "
+               BT_COMP_LOGE("Unsupported contiguous discarded packets message: "
                        "stream-id=%" PRIu64 ", stream-name=\"%s\", "
                        "trace-name=\"%s\", path=\"%s/%s\"",
                        bt_stream_get_id(ir_stream),
@@ -940,7 +941,7 @@ bt_self_component_status ctf_fs_sink_consume(bt_self_component_sink *self_comp)
                                break;
                        case BT_MESSAGE_TYPE_MESSAGE_ITERATOR_INACTIVITY:
                                /* Ignore */
-                               BT_LOGD_STR("Ignoring message iterator inactivity message.");
+                               BT_COMP_LOGD_STR("Ignoring message iterator inactivity message.");
                                break;
                        case BT_MESSAGE_TYPE_STREAM_BEGINNING:
                                status = handle_stream_beginning_msg(
@@ -953,7 +954,7 @@ bt_self_component_status ctf_fs_sink_consume(bt_self_component_sink *self_comp)
                        case BT_MESSAGE_TYPE_STREAM_ACTIVITY_BEGINNING:
                        case BT_MESSAGE_TYPE_STREAM_ACTIVITY_END:
                                /* Not supported by CTF 1.8 */
-                               BT_LOGD_STR("Ignoring stream activity message.");
+                               BT_COMP_LOGD_STR("Ignoring stream activity message.");
                                break;
                        case BT_MESSAGE_TYPE_DISCARDED_EVENTS:
                                status = handle_discarded_events_msg(
@@ -970,7 +971,7 @@ bt_self_component_status ctf_fs_sink_consume(bt_self_component_sink *self_comp)
                        BT_MESSAGE_PUT_REF_AND_RESET(msgs[i]);
 
                        if (status != BT_SELF_COMPONENT_STATUS_OK) {
-                               BT_LOGE("Failed to handle message: "
+                               BT_COMP_LOGE("Failed to handle message: "
                                        "generated CTF traces could be incomplete: "
                                        "output-dir-path=\"%s\"",
                                        fs_sink->output_dir_path->str);
index ccdf3b3c7482c0685c50890ef44abbea71c8d8f3..e59e1249b0e64def79a41cc9006d8b1d758bd594 100644 (file)
@@ -30,7 +30,7 @@
 
 struct fs_sink_comp {
        bt_logging_level log_level;
-       bt_self_component_sink *self_comp;
+       bt_self_component *self_comp;
 
        /* Owned by this */
        bt_self_component_port_input_message_iterator *upstream_iter;
index a4f9761de76f6c7e5c0e87f868794ebb85a7d093..4d6f572ac1760df430335f2270d82a6d2bac7051 100644 (file)
  * SOFTWARE.
  */
 
+#define BT_COMP_LOG_SELF_COMP (ctx->self_comp)
 #define BT_LOG_OUTPUT_LEVEL (ctx->log_level)
 #define BT_LOG_TAG "PLUGIN/SINK.CTF.FS/TRANSLATE-TRACE-IR-TO-CTF-IR"
-#include "logging/log.h"
+#include "plugins/comp-logging.h"
 
 #include <babeltrace2/babeltrace.h>
 #include "common/macros.h"
@@ -33,6 +34,7 @@
 #include <string.h>
 #include <glib.h>
 
+#include "fs-sink.h"
 #include "fs-sink-ctf-meta.h"
 
 struct field_path_elem {
@@ -48,6 +50,7 @@ struct field_path_elem {
 
 struct ctx {
        bt_logging_level log_level;
+       bt_self_component *self_comp;
 
        /* Weak */
        struct fs_sink_ctf_stream_class *cur_sc;
@@ -117,7 +120,7 @@ int cur_path_stack_push(struct ctx *ctx,
                                        is_reserved_member_name(ir_name, "timestamp_end") ||
                                        is_reserved_member_name(ir_name, "events_discarded") ||
                                        is_reserved_member_name(ir_name, "packet_seq_num")) {
-                               BT_LOGE("Unsupported reserved TSDL structure field class member "
+                               BT_COMP_LOGE("Unsupported reserved TSDL structure field class member "
                                        "or variant field class option name: name=\"%s\"",
                                        ir_name);
                                ret = -1;
@@ -127,7 +130,7 @@ int cur_path_stack_push(struct ctx *ctx,
 
                ret = fs_sink_ctf_protect_name(field_path_elem->name);
                if (ret) {
-                       BT_LOGE("Unsupported non-TSDL structure field class member "
+                       BT_COMP_LOGE("Unsupported non-TSDL structure field class member "
                                "or variant field class option name: name=\"%s\"",
                                ir_name);
                        goto end;
@@ -551,14 +554,14 @@ int translate_structure_field_class_members(struct ctx *ctx,
                ret = cur_path_stack_push(ctx, i, name, memb_ir_fc,
                        (void *) struct_fc);
                if (ret) {
-                       BT_LOGE("Cannot translate structure field class member: "
+                       BT_COMP_LOGE("Cannot translate structure field class member: "
                                "name=\"%s\"", name);
                        goto end;
                }
 
                ret = translate_field_class(ctx);
                if (ret) {
-                       BT_LOGE("Cannot translate structure field class member: "
+                       BT_COMP_LOGE("Cannot translate structure field class member: "
                                "name=\"%s\"", name);
                        goto end;
                }
@@ -624,14 +627,14 @@ int translate_variant_field_class(struct ctx *ctx)
                        opt);
                ret = cur_path_stack_push(ctx, i, name, opt_ir_fc, (void *) fc);
                if (ret) {
-                       BT_LOGE("Cannot translate variant field class option: "
+                       BT_COMP_LOGE("Cannot translate variant field class option: "
                                "name=\"%s\"", name);
                        goto end;
                }
 
                ret = translate_field_class(ctx);
                if (ret) {
-                       BT_LOGE("Cannot translate variant field class option: "
+                       BT_COMP_LOGE("Cannot translate variant field class option: "
                                "name=\"%s\"", name);
                        goto end;
                }
@@ -660,13 +663,13 @@ int translate_static_array_field_class(struct ctx *ctx)
        ret = cur_path_stack_push(ctx, UINT64_C(-1), NULL, elem_ir_fc,
                (void *) fc);
        if (ret) {
-               BT_LOGE_STR("Cannot translate static array field class element.");
+               BT_COMP_LOGE_STR("Cannot translate static array field class element.");
                goto end;
        }
 
        ret = translate_field_class(ctx);
        if (ret) {
-               BT_LOGE_STR("Cannot translate static array field class element.");
+               BT_COMP_LOGE_STR("Cannot translate static array field class element.");
                goto end;
        }
 
@@ -701,13 +704,13 @@ int translate_dynamic_array_field_class(struct ctx *ctx)
        ret = cur_path_stack_push(ctx, UINT64_C(-1), NULL, elem_ir_fc,
                (void *) fc);
        if (ret) {
-               BT_LOGE_STR("Cannot translate dynamic array field class element.");
+               BT_COMP_LOGE_STR("Cannot translate dynamic array field class element.");
                goto end;
        }
 
        ret = translate_field_class(ctx);
        if (ret) {
-               BT_LOGE_STR("Cannot translate dynamic array field class element.");
+               BT_COMP_LOGE_STR("Cannot translate dynamic array field class element.");
                goto end;
        }
 
@@ -1008,14 +1011,14 @@ int translate_scope_field_class(struct ctx *ctx, bt_scope scope,
        BT_ASSERT(ctx->cur_path->len == 0);
        ret = cur_path_stack_push(ctx, UINT64_C(-1), NULL, ir_fc, NULL);
        if (ret) {
-               BT_LOGE("Cannot translate scope structure field class: "
+               BT_COMP_LOGE("Cannot translate scope structure field class: "
                        "scope=%d", scope);
                goto end;
        }
 
        ret = translate_structure_field_class_members(ctx, (void *) *fc, ir_fc);
        if (ret) {
-               BT_LOGE("Cannot translate scope structure field class: "
+               BT_COMP_LOGE("Cannot translate scope structure field class: "
                        "scope=%d", scope);
                goto end;
        }
@@ -1030,13 +1033,14 @@ end:
 }
 
 static inline
-void ctx_init(struct ctx *ctx, bt_logging_level log_level)
+void ctx_init(struct ctx *ctx, struct fs_sink_comp *fs_sink)
 {
        memset(ctx, 0, sizeof(struct ctx));
        ctx->cur_path = g_array_new(FALSE, TRUE,
                sizeof(struct field_path_elem));
        BT_ASSERT(ctx->cur_path);
-       ctx->log_level = log_level;
+       ctx->log_level = fs_sink->log_level;
+       ctx->self_comp = fs_sink->self_comp;
 }
 
 static inline
@@ -1049,10 +1053,10 @@ void ctx_fini(struct ctx *ctx)
 }
 
 static
-int translate_event_class(struct fs_sink_ctf_stream_class *sc,
+int translate_event_class(struct fs_sink_comp *fs_sink,
+               struct fs_sink_ctf_stream_class *sc,
                const bt_event_class *ir_ec,
-               struct fs_sink_ctf_event_class **out_ec,
-               bt_logging_level log_level)
+               struct fs_sink_ctf_event_class **out_ec)
 {
        int ret = 0;
        struct ctx ctx;
@@ -1061,7 +1065,7 @@ int translate_event_class(struct fs_sink_ctf_stream_class *sc,
        BT_ASSERT(sc);
        BT_ASSERT(ir_ec);
 
-       ctx_init(&ctx, log_level);
+       ctx_init(&ctx, fs_sink);
        ec = fs_sink_ctf_event_class_create(sc, ir_ec);
        BT_ASSERT(ec);
        ctx.cur_sc = sc;
@@ -1089,10 +1093,10 @@ end:
 
 BT_HIDDEN
 int try_translate_event_class_trace_ir_to_ctf_ir(
+               struct fs_sink_comp *fs_sink,
                struct fs_sink_ctf_stream_class *sc,
                const bt_event_class *ir_ec,
-               struct fs_sink_ctf_event_class **out_ec,
-               bt_logging_level log_level)
+               struct fs_sink_ctf_event_class **out_ec)
 {
        int ret = 0;
 
@@ -1105,7 +1109,7 @@ int try_translate_event_class_trace_ir_to_ctf_ir(
                goto end;
        }
 
-       ret = translate_event_class(sc, ir_ec, out_ec, log_level);
+       ret = translate_event_class(fs_sink, sc, ir_ec, out_ec);
 
 end:
        return ret;
@@ -1154,17 +1158,17 @@ void make_unique_default_clock_class_name(struct fs_sink_ctf_stream_class *sc)
 }
 
 static
-int translate_stream_class(struct fs_sink_ctf_trace_class *tc,
+int translate_stream_class(struct fs_sink_comp *fs_sink,
+               struct fs_sink_ctf_trace_class *tc,
                const bt_stream_class *ir_sc,
-               struct fs_sink_ctf_stream_class **out_sc,
-               bt_logging_level log_level)
+               struct fs_sink_ctf_stream_class **out_sc)
 {
        int ret = 0;
        struct ctx ctx;
 
        BT_ASSERT(tc);
        BT_ASSERT(ir_sc);
-       ctx_init(&ctx, log_level);
+       ctx_init(&ctx, fs_sink);
        *out_sc = fs_sink_ctf_stream_class_create(tc, ir_sc);
        BT_ASSERT(*out_sc);
 
@@ -1229,10 +1233,10 @@ end:
 
 BT_HIDDEN
 int try_translate_stream_class_trace_ir_to_ctf_ir(
+               struct fs_sink_comp *fs_sink,
                struct fs_sink_ctf_trace_class *tc,
                const bt_stream_class *ir_sc,
-               struct fs_sink_ctf_stream_class **out_sc,
-               bt_logging_level log_level)
+               struct fs_sink_ctf_stream_class **out_sc)
 {
        int ret = 0;
        uint64_t i;
@@ -1248,7 +1252,7 @@ int try_translate_stream_class_trace_ir_to_ctf_ir(
                }
        }
 
-       ret = translate_stream_class(tc, ir_sc, out_sc, log_level);
+       ret = translate_stream_class(fs_sink, tc, ir_sc, out_sc);
 
 end:
        return ret;
@@ -1256,7 +1260,7 @@ end:
 
 BT_HIDDEN
 struct fs_sink_ctf_trace_class *translate_trace_class_trace_ir_to_ctf_ir(
-               const bt_trace_class *ir_tc, bt_logging_level log_level)
+               struct fs_sink_comp *fs_sink, const bt_trace_class *ir_tc)
 {
        uint64_t count;
        uint64_t i;
@@ -1272,8 +1276,8 @@ struct fs_sink_ctf_trace_class *translate_trace_class_trace_ir_to_ctf_ir(
                        ir_tc, i, &name, &val);
 
                if (!fs_sink_ctf_ist_valid_identifier(name)) {
-                       BT_LOG_WRITE_CUR_LVL(BT_LOG_ERROR, log_level,
-                               BT_LOG_TAG,
+                       BT_COMP_LOG_CUR_LVL(BT_LOG_ERROR, fs_sink->log_level,
+                               fs_sink->self_comp,
                                "Unsupported trace class's environment entry name: "
                                "name=\"%s\"", name);
                        goto end;
@@ -1284,8 +1288,8 @@ struct fs_sink_ctf_trace_class *translate_trace_class_trace_ir_to_ctf_ir(
                case BT_VALUE_TYPE_STRING:
                        break;
                default:
-                       BT_LOG_WRITE_CUR_LVL(BT_LOG_ERROR, log_level,
-                               BT_LOG_TAG,
+                       BT_COMP_LOG_CUR_LVL(BT_LOG_ERROR, fs_sink->log_level,
+                               fs_sink->self_comp,
                                "Unsupported trace class's environment entry value type: "
                                "type=%s",
                                bt_common_value_type_string(
index 8abba50f38190a2eebd33136d625003f2fa39be9..495667e37db33447d449146c3e32d1cf0a9a732a 100644 (file)
 #include "common/macros.h"
 #include <babeltrace2/babeltrace.h>
 
+#include "fs-sink.h"
 #include "fs-sink-ctf-meta.h"
 
 BT_HIDDEN
 int try_translate_event_class_trace_ir_to_ctf_ir(
+               struct fs_sink_comp *fs_sink,
                struct fs_sink_ctf_stream_class *sc,
                const bt_event_class *ir_ec,
-               struct fs_sink_ctf_event_class **out_ec,
-               bt_logging_level log_level);
+               struct fs_sink_ctf_event_class **out_ec);
 
 BT_HIDDEN
 int try_translate_stream_class_trace_ir_to_ctf_ir(
+               struct fs_sink_comp *fs_sink,
                struct fs_sink_ctf_trace_class *tc,
                const bt_stream_class *ir_sc,
-               struct fs_sink_ctf_stream_class **out_sc,
-               bt_logging_level log_level);
+               struct fs_sink_ctf_stream_class **out_sc);
 
 BT_HIDDEN
 struct fs_sink_ctf_trace_class *translate_trace_class_trace_ir_to_ctf_ir(
-               const bt_trace_class *ir_tc, bt_logging_level log_level);
+               struct fs_sink_comp *fs_sink, const bt_trace_class *ir_tc);
 
 #endif /* BABELTRACE_PLUGIN_CTF_FS_SINK_TRANSLATE_TRACE_IR_TO_CTF_IR_H */
This page took 0.040444 seconds and 4 git commands to generate.