doc/api/libbabeltrace2/DoxygenLayout.xml: use `topics` tab
[babeltrace.git] / src / plugins / ctf / fs-sink / translate-trace-ir-to-ctf-ir.cpp
index 88bff0bf7c0806de89c0afe340328ad9b67b22fb..ca634b952aba11b45143748c9b34a37824c0ca46 100644 (file)
@@ -7,20 +7,15 @@
 #include <string>
 
 #include <glib.h>
-#include <stdbool.h>
 #include <stdio.h>
 #include <string.h>
 
 #include <babeltrace2/babeltrace.h>
 
-#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/comp-logging.h"
-
 #include "common/assert.h"
 #include "common/common.h"
-#include "common/macros.h"
+#include "cpp-common/bt2/field-path.hpp"
+#include "cpp-common/bt2c/fmt.hpp"
 
 #include "fs-sink-ctf-meta.hpp"
 #include "fs-sink.hpp"
@@ -28,7 +23,6 @@
 
 struct field_path_elem
 {
-    uint64_t index_in_parent;
     GString *name;
 
     /* Weak */
@@ -38,31 +32,42 @@ struct field_path_elem
     struct fs_sink_ctf_field_class *parent_fc;
 };
 
-struct ctx
+namespace ctf {
+namespace sink {
+
+struct TraceIrToCtfIrCtx
 {
-    bt_logging_level log_level;
-    bt_self_component *self_comp;
+    explicit TraceIrToCtfIrCtx(const bt2c::Logger& parentLogger) :
+        logger {parentLogger, "PLUGIN/SINK.CTF.FS/TRANSLATE-TRACE-IR-TO-CTF-IR"}
+    {
+    }
+
+    bt2c::Logger logger;
 
     /* Weak */
-    struct fs_sink_ctf_stream_class *cur_sc;
+    struct fs_sink_ctf_stream_class *cur_sc = nullptr;
 
     /* Weak */
-    struct fs_sink_ctf_event_class *cur_ec;
+    struct fs_sink_ctf_event_class *cur_ec = nullptr;
 
-    bt_field_path_scope cur_scope;
+    bt_field_path_scope cur_scope = BT_FIELD_PATH_SCOPE_PACKET_CONTEXT;
 
     /*
      * Array of `struct field_path_elem` */
-    GArray *cur_path;
+    GArray *cur_path = nullptr;
 };
 
-static inline struct field_path_elem *cur_path_stack_at(struct ctx *ctx, uint64_t i)
+} /* namespace sink */
+} /* namespace ctf */
+
+static inline struct field_path_elem *cur_path_stack_at(ctf::sink::TraceIrToCtfIrCtx *ctx,
+                                                        uint64_t i)
 {
     BT_ASSERT(i < ctx->cur_path->len);
     return &bt_g_array_index(ctx->cur_path, struct field_path_elem, i);
 }
 
-static inline struct field_path_elem *cur_path_stack_top(struct ctx *ctx)
+static inline struct field_path_elem *cur_path_stack_top(ctf::sink::TraceIrToCtfIrCtx *ctx)
 {
     BT_ASSERT(ctx->cur_path->len > 0);
     return cur_path_stack_at(ctx, ctx->cur_path->len - 1);
@@ -154,7 +159,7 @@ end:
     return must_protect;
 }
 
-static inline int cur_path_stack_push(struct ctx *ctx, uint64_t index_in_parent, const char *name,
+static inline int cur_path_stack_push(ctf::sink::TraceIrToCtfIrCtx *ctx, const char *name,
                                       bool force_protect_name, const bt_field_class *ir_fc,
                                       struct fs_sink_ctf_field_class *parent_fc)
 {
@@ -163,7 +168,6 @@ static inline int cur_path_stack_push(struct ctx *ctx, uint64_t index_in_parent,
 
     g_array_set_size(ctx->cur_path, ctx->cur_path->len + 1);
     field_path_elem = cur_path_stack_top(ctx);
-    field_path_elem->index_in_parent = index_in_parent;
     field_path_elem->name = g_string_new(NULL);
 
     if (name) {
@@ -180,9 +184,10 @@ static inline int cur_path_stack_push(struct ctx *ctx, uint64_t index_in_parent,
                 is_reserved_member_name(name, "timestamp_end") ||
                 is_reserved_member_name(name, "events_discarded") ||
                 is_reserved_member_name(name, "packet_seq_num")) {
-                BT_COMP_LOGE("Unsupported reserved TSDL structure field class member "
-                             "or variant field class option name: name=\"%s\"",
-                             name);
+                BT_CPPLOGE_SPEC(ctx->logger,
+                                "Unsupported reserved TSDL structure field class member "
+                                "or variant field class option name: name=\"{}\"",
+                                name);
                 ret = -1;
                 goto end;
             }
@@ -190,9 +195,10 @@ static inline int cur_path_stack_push(struct ctx *ctx, uint64_t index_in_parent,
 
         if (!ist_valid_identifier(field_path_elem->name->str)) {
             ret = -1;
-            BT_COMP_LOGE("Unsupported non-TSDL structure field class member "
-                         "or variant field class option name: name=\"%s\"",
-                         field_path_elem->name->str);
+            BT_CPPLOGE_SPEC(ctx->logger,
+                            "Unsupported non-TSDL structure field class member "
+                            "or variant field class option name: name=\"{}\"",
+                            field_path_elem->name->str);
             goto end;
         }
     }
@@ -204,7 +210,7 @@ end:
     return ret;
 }
 
-static inline void cur_path_stack_pop(struct ctx *ctx)
+static inline void cur_path_stack_pop(ctf::sink::TraceIrToCtfIrCtx *ctx)
 {
     struct field_path_elem *field_path_elem;
 
@@ -231,8 +237,8 @@ static inline void cur_path_stack_pop(struct ctx *ctx)
  *
  * Returns a negative value if this resolving operation failed.
  */
-static int create_relative_field_ref(struct ctx *ctx, const bt_field_path *tgt_ir_field_path,
-                                     GString *tgt_field_ref,
+static int create_relative_field_ref(ctf::sink::TraceIrToCtfIrCtx *ctx,
+                                     const bt_field_path *tgt_ir_field_path, GString *tgt_field_ref,
                                      struct fs_sink_ctf_field_class **user_tgt_fc)
 {
     int ret = 0;
@@ -396,8 +402,8 @@ end:
  *
  * Returns a negative value if this resolving operation failed.
  */
-static int create_absolute_field_ref(struct ctx *ctx, const bt_field_path *tgt_ir_field_path,
-                                     GString *tgt_field_ref,
+static int create_absolute_field_ref(ctf::sink::TraceIrToCtfIrCtx *ctx,
+                                     const bt_field_path *tgt_ir_field_path, GString *tgt_field_ref,
                                      struct fs_sink_ctf_field_class **user_tgt_fc)
 {
     int ret = 0;
@@ -479,9 +485,9 @@ end:
  * created immediately before (in which case `tgt_field_ref` is
  * irrelevant).
  */
-static void resolve_field_class(struct ctx *ctx, const bt_field_path *tgt_ir_field_path,
-                                GString *tgt_field_ref, bool *create_before,
-                                struct fs_sink_ctf_field_class **user_tgt_fc)
+static void resolve_field_class(ctf::sink::TraceIrToCtfIrCtx *ctx,
+                                const bt_field_path *tgt_ir_field_path, GString *tgt_field_ref,
+                                bool *create_before, struct fs_sink_ctf_field_class **user_tgt_fc)
 {
     int ret;
     bt_field_path_scope tgt_scope;
@@ -529,9 +535,10 @@ end:
     return;
 }
 
-static int translate_field_class(struct ctx *ctx);
+static int translate_field_class(ctf::sink::TraceIrToCtfIrCtx *ctx);
 
-static inline void append_to_parent_field_class(struct ctx *ctx, struct fs_sink_ctf_field_class *fc)
+static inline void append_to_parent_field_class(ctf::sink::TraceIrToCtfIrCtx *ctx,
+                                                struct fs_sink_ctf_field_class *fc)
 {
     struct fs_sink_ctf_field_class *parent_fc = cur_path_stack_top(ctx)->parent_fc;
 
@@ -570,7 +577,8 @@ static inline void append_to_parent_field_class(struct ctx *ctx, struct fs_sink_
     }
 }
 
-static inline void update_parent_field_class_alignment(struct ctx *ctx, unsigned int alignment)
+static inline void update_parent_field_class_alignment(ctf::sink::TraceIrToCtfIrCtx *ctx,
+                                                       unsigned int alignment)
 {
     struct fs_sink_ctf_field_class *parent_fc = cur_path_stack_top(ctx)->parent_fc;
 
@@ -593,8 +601,10 @@ static inline void update_parent_field_class_alignment(struct ctx *ctx, unsigned
     }
 }
 
-static inline int translate_structure_field_class_members(
-    struct ctx *ctx, struct fs_sink_ctf_field_class_struct *struct_fc, const bt_field_class *ir_fc)
+static inline int
+translate_structure_field_class_members(ctf::sink::TraceIrToCtfIrCtx *ctx,
+                                        struct fs_sink_ctf_field_class_struct *struct_fc,
+                                        const bt_field_class *ir_fc)
 {
     int ret = 0;
     uint64_t i;
@@ -607,19 +617,21 @@ static inline int translate_structure_field_class_members(
         member = bt_field_class_structure_borrow_member_by_index_const(ir_fc, i);
         name = bt_field_class_structure_member_get_name(member);
         memb_ir_fc = bt_field_class_structure_member_borrow_field_class_const(member);
-        ret = cur_path_stack_push(ctx, i, name, true, memb_ir_fc, &struct_fc->base);
+        ret = cur_path_stack_push(ctx, name, true, memb_ir_fc, &struct_fc->base);
         if (ret) {
-            BT_COMP_LOGE("Cannot translate structure field class member: "
-                         "name=\"%s\"",
-                         name);
+            BT_CPPLOGE_SPEC(ctx->logger,
+                            "Cannot translate structure field class member: "
+                            "name=\"{}\"",
+                            name);
             goto end;
         }
 
         ret = translate_field_class(ctx);
         if (ret) {
-            BT_COMP_LOGE("Cannot translate structure field class member: "
-                         "name=\"%s\"",
-                         name);
+            BT_CPPLOGE_SPEC(ctx->logger,
+                            "Cannot translate structure field class member: "
+                            "name=\"{}\"",
+                            name);
             goto end;
         }
 
@@ -630,11 +642,11 @@ end:
     return ret;
 }
 
-static inline int translate_structure_field_class(struct ctx *ctx)
+static inline int translate_structure_field_class(ctf::sink::TraceIrToCtfIrCtx *ctx)
 {
     int ret;
-    struct fs_sink_ctf_field_class_struct *fc = fs_sink_ctf_field_class_struct_create_empty(
-        cur_path_stack_top(ctx)->ir_fc, cur_path_stack_top(ctx)->index_in_parent);
+    struct fs_sink_ctf_field_class_struct *fc =
+        fs_sink_ctf_field_class_struct_create_empty(cur_path_stack_top(ctx)->ir_fc);
 
     BT_ASSERT(fc);
     append_to_parent_field_class(ctx, &fc->base);
@@ -844,10 +856,10 @@ end:
     return ret;
 }
 
-static inline int translate_option_field_class(struct ctx *ctx)
+static inline int translate_option_field_class(ctf::sink::TraceIrToCtfIrCtx *ctx)
 {
-    struct fs_sink_ctf_field_class_option *fc = fs_sink_ctf_field_class_option_create_empty(
-        cur_path_stack_top(ctx)->ir_fc, cur_path_stack_top(ctx)->index_in_parent);
+    struct fs_sink_ctf_field_class_option *fc =
+        fs_sink_ctf_field_class_option_create_empty(cur_path_stack_top(ctx)->ir_fc);
     const bt_field_class *content_ir_fc =
         bt_field_class_option_borrow_field_class_const(fc->base.ir_fc);
     int ret;
@@ -866,15 +878,15 @@ static inline int translate_option_field_class(struct ctx *ctx)
      * unsigned enumeration field class).
      */
     append_to_parent_field_class(ctx, &fc->base);
-    ret = cur_path_stack_push(ctx, UINT64_C(-1), NULL, false, content_ir_fc, &fc->base);
+    ret = cur_path_stack_push(ctx, NULL, false, content_ir_fc, &fc->base);
     if (ret) {
-        BT_COMP_LOGE_STR("Cannot translate option field class content.");
+        BT_CPPLOGE_SPEC(ctx->logger, "Cannot translate option field class content.");
         goto end;
     }
 
     ret = translate_field_class(ctx);
     if (ret) {
-        BT_COMP_LOGE_STR("Cannot translate option field class content.");
+        BT_CPPLOGE_SPEC(ctx->logger, "Cannot translate option field class content.");
         goto end;
     }
 
@@ -885,12 +897,12 @@ end:
     return ret;
 }
 
-static inline int translate_variant_field_class(struct ctx *ctx)
+static inline int translate_variant_field_class(ctf::sink::TraceIrToCtfIrCtx *ctx)
 {
     int ret = 0;
     uint64_t i;
-    struct fs_sink_ctf_field_class_variant *fc = fs_sink_ctf_field_class_variant_create_empty(
-        cur_path_stack_top(ctx)->ir_fc, cur_path_stack_top(ctx)->index_in_parent);
+    struct fs_sink_ctf_field_class_variant *fc =
+        fs_sink_ctf_field_class_variant_create_empty(cur_path_stack_top(ctx)->ir_fc);
     bt_field_class_type ir_fc_type;
     const bt_field_path *ir_selector_field_path = NULL;
     struct fs_sink_ctf_field_class *tgt_fc = NULL;
@@ -1017,19 +1029,21 @@ append_to_parent:
          * option name because it's already protected at this
          * point.
          */
-        ret = cur_path_stack_push(ctx, i, prot_opt_name, false, opt_ir_fc, &fc->base);
+        ret = cur_path_stack_push(ctx, prot_opt_name, false, opt_ir_fc, &fc->base);
         if (ret) {
-            BT_COMP_LOGE("Cannot translate variant field class option: "
-                         "name=\"%s\"",
-                         prot_opt_name);
+            BT_CPPLOGE_SPEC(ctx->logger,
+                            "Cannot translate variant field class option: "
+                            "name=\"{}\"",
+                            prot_opt_name);
             goto end;
         }
 
         ret = translate_field_class(ctx);
         if (ret) {
-            BT_COMP_LOGE("Cannot translate variant field class option: "
-                         "name=\"%s\"",
-                         prot_opt_name);
+            BT_CPPLOGE_SPEC(ctx->logger,
+                            "Cannot translate variant field class option: "
+                            "name=\"{}\"",
+                            prot_opt_name);
             goto end;
         }
 
@@ -1045,25 +1059,25 @@ end:
     return ret;
 }
 
-static inline int translate_static_array_field_class(struct ctx *ctx)
+static inline int translate_static_array_field_class(ctf::sink::TraceIrToCtfIrCtx *ctx)
 {
-    struct fs_sink_ctf_field_class_array *fc = fs_sink_ctf_field_class_array_create_empty(
-        cur_path_stack_top(ctx)->ir_fc, cur_path_stack_top(ctx)->index_in_parent);
+    struct fs_sink_ctf_field_class_array *fc =
+        fs_sink_ctf_field_class_array_create_empty(cur_path_stack_top(ctx)->ir_fc);
     const bt_field_class *elem_ir_fc =
         bt_field_class_array_borrow_element_field_class_const(fc->base.base.ir_fc);
     int ret;
 
     BT_ASSERT(fc);
     append_to_parent_field_class(ctx, &fc->base.base);
-    ret = cur_path_stack_push(ctx, UINT64_C(-1), NULL, false, elem_ir_fc, &fc->base.base);
+    ret = cur_path_stack_push(ctx, NULL, false, elem_ir_fc, &fc->base.base);
     if (ret) {
-        BT_COMP_LOGE_STR("Cannot translate static array field class element.");
+        BT_CPPLOGE_SPEC(ctx->logger, "Cannot translate static array field class element.");
         goto end;
     }
 
     ret = translate_field_class(ctx);
     if (ret) {
-        BT_COMP_LOGE_STR("Cannot translate static array field class element.");
+        BT_CPPLOGE_SPEC(ctx->logger, "Cannot translate static array field class element.");
         goto end;
     }
 
@@ -1074,10 +1088,10 @@ end:
     return ret;
 }
 
-static inline int translate_dynamic_array_field_class(struct ctx *ctx)
+static inline int translate_dynamic_array_field_class(ctf::sink::TraceIrToCtfIrCtx *ctx)
 {
-    struct fs_sink_ctf_field_class_sequence *fc = fs_sink_ctf_field_class_sequence_create_empty(
-        cur_path_stack_top(ctx)->ir_fc, cur_path_stack_top(ctx)->index_in_parent);
+    struct fs_sink_ctf_field_class_sequence *fc =
+        fs_sink_ctf_field_class_sequence_create_empty(cur_path_stack_top(ctx)->ir_fc);
     const bt_field_class *elem_ir_fc =
         bt_field_class_array_borrow_element_field_class_const(fc->base.base.ir_fc);
     int ret;
@@ -1095,15 +1109,15 @@ static inline int translate_dynamic_array_field_class(struct ctx *ctx)
     }
 
     append_to_parent_field_class(ctx, &fc->base.base);
-    ret = cur_path_stack_push(ctx, UINT64_C(-1), NULL, false, elem_ir_fc, &fc->base.base);
+    ret = cur_path_stack_push(ctx, NULL, false, elem_ir_fc, &fc->base.base);
     if (ret) {
-        BT_COMP_LOGE_STR("Cannot translate dynamic array field class element.");
+        BT_CPPLOGE_SPEC(ctx->logger, "Cannot translate dynamic array field class element.");
         goto end;
     }
 
     ret = translate_field_class(ctx);
     if (ret) {
-        BT_COMP_LOGE_STR("Cannot translate dynamic array field class element.");
+        BT_CPPLOGE_SPEC(ctx->logger, "Cannot translate dynamic array field class element.");
         goto end;
     }
 
@@ -1114,50 +1128,50 @@ end:
     return ret;
 }
 
-static inline int translate_bool_field_class(struct ctx *ctx)
+static inline int translate_bool_field_class(ctf::sink::TraceIrToCtfIrCtx *ctx)
 {
-    struct fs_sink_ctf_field_class_bool *fc = fs_sink_ctf_field_class_bool_create(
-        cur_path_stack_top(ctx)->ir_fc, cur_path_stack_top(ctx)->index_in_parent);
+    struct fs_sink_ctf_field_class_bool *fc =
+        fs_sink_ctf_field_class_bool_create(cur_path_stack_top(ctx)->ir_fc);
 
     BT_ASSERT(fc);
     append_to_parent_field_class(ctx, &fc->base.base);
     return 0;
 }
 
-static inline int translate_bit_array_field_class(struct ctx *ctx)
+static inline int translate_bit_array_field_class(ctf::sink::TraceIrToCtfIrCtx *ctx)
 {
-    struct fs_sink_ctf_field_class_bit_array *fc = fs_sink_ctf_field_class_bit_array_create(
-        cur_path_stack_top(ctx)->ir_fc, cur_path_stack_top(ctx)->index_in_parent);
+    struct fs_sink_ctf_field_class_bit_array *fc =
+        fs_sink_ctf_field_class_bit_array_create(cur_path_stack_top(ctx)->ir_fc);
 
     BT_ASSERT(fc);
     append_to_parent_field_class(ctx, &fc->base);
     return 0;
 }
 
-static inline int translate_integer_field_class(struct ctx *ctx)
+static inline int translate_integer_field_class(ctf::sink::TraceIrToCtfIrCtx *ctx)
 {
-    struct fs_sink_ctf_field_class_int *fc = fs_sink_ctf_field_class_int_create(
-        cur_path_stack_top(ctx)->ir_fc, cur_path_stack_top(ctx)->index_in_parent);
+    struct fs_sink_ctf_field_class_int *fc =
+        fs_sink_ctf_field_class_int_create(cur_path_stack_top(ctx)->ir_fc);
 
     BT_ASSERT(fc);
     append_to_parent_field_class(ctx, &fc->base.base);
     return 0;
 }
 
-static inline int translate_real_field_class(struct ctx *ctx)
+static inline int translate_real_field_class(ctf::sink::TraceIrToCtfIrCtx *ctx)
 {
-    struct fs_sink_ctf_field_class_float *fc = fs_sink_ctf_field_class_float_create(
-        cur_path_stack_top(ctx)->ir_fc, cur_path_stack_top(ctx)->index_in_parent);
+    struct fs_sink_ctf_field_class_float *fc =
+        fs_sink_ctf_field_class_float_create(cur_path_stack_top(ctx)->ir_fc);
 
     BT_ASSERT(fc);
     append_to_parent_field_class(ctx, &fc->base.base);
     return 0;
 }
 
-static inline int translate_string_field_class(struct ctx *ctx)
+static inline int translate_string_field_class(ctf::sink::TraceIrToCtfIrCtx *ctx)
 {
-    struct fs_sink_ctf_field_class_string *fc = fs_sink_ctf_field_class_string_create(
-        cur_path_stack_top(ctx)->ir_fc, cur_path_stack_top(ctx)->index_in_parent);
+    struct fs_sink_ctf_field_class_string *fc =
+        fs_sink_ctf_field_class_string_create(cur_path_stack_top(ctx)->ir_fc);
 
     BT_ASSERT(fc);
     append_to_parent_field_class(ctx, &fc->base);
@@ -1171,7 +1185,7 @@ static inline int translate_string_field_class(struct ctx *ctx)
  * within its parent are in the context's current path's top element
  * (cur_path_stack_top()).
  */
-static int translate_field_class(struct ctx *ctx)
+static int translate_field_class(ctf::sink::TraceIrToCtfIrCtx *ctx)
 {
     int ret;
     bt_field_class_type ir_fc_type = bt_field_class_get_type(cur_path_stack_top(ctx)->ir_fc);
@@ -1421,7 +1435,7 @@ end:
  * class and then calls translate_structure_field_class_members() to
  * fill it.
  */
-static int translate_scope_field_class(struct ctx *ctx, bt_field_path_scope scope,
+static int translate_scope_field_class(ctf::sink::TraceIrToCtfIrCtx *ctx, bt_field_path_scope scope,
                                        struct fs_sink_ctf_field_class **fc,
                                        const bt_field_class *ir_fc)
 {
@@ -1433,24 +1447,22 @@ static int translate_scope_field_class(struct ctx *ctx, bt_field_path_scope scop
 
     BT_ASSERT(bt_field_class_get_type(ir_fc) == BT_FIELD_CLASS_TYPE_STRUCTURE);
     BT_ASSERT(fc);
-    *fc = &fs_sink_ctf_field_class_struct_create_empty(ir_fc, UINT64_C(-1))->base;
+    *fc = &fs_sink_ctf_field_class_struct_create_empty(ir_fc)->base;
     BT_ASSERT(*fc);
     ctx->cur_scope = scope;
     BT_ASSERT(ctx->cur_path->len == 0);
-    ret = cur_path_stack_push(ctx, UINT64_C(-1), NULL, false, ir_fc, NULL);
+    ret = cur_path_stack_push(ctx, NULL, false, ir_fc, NULL);
     if (ret) {
-        BT_COMP_LOGE("Cannot translate scope structure field class: "
-                     "scope=%d",
-                     scope);
+        BT_CPPLOGE_SPEC(ctx->logger, "Cannot translate scope structure field class: scope={}",
+                        static_cast<bt2::FieldPathScope>(scope));
         goto end;
     }
 
     ret =
         translate_structure_field_class_members(ctx, fs_sink_ctf_field_class_as_struct(*fc), ir_fc);
     if (ret) {
-        BT_COMP_LOGE("Cannot translate scope structure field class: "
-                     "scope=%d",
-                     scope);
+        BT_CPPLOGE_SPEC(ctx->logger, "Cannot translate scope structure field class: scope={}",
+                        static_cast<bt2::FieldPathScope>(scope));
         goto end;
     }
 
@@ -1463,16 +1475,13 @@ end:
     return ret;
 }
 
-static inline void ctx_init(struct ctx *ctx, struct fs_sink_comp *fs_sink)
+static inline void ctx_init(ctf::sink::TraceIrToCtfIrCtx *ctx)
 {
-    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 = fs_sink->log_level;
-    ctx->self_comp = fs_sink->self_comp;
 }
 
-static inline void ctx_fini(struct ctx *ctx)
+static inline void ctx_fini(ctf::sink::TraceIrToCtfIrCtx *ctx)
 {
     if (ctx->cur_path) {
         g_array_free(ctx->cur_path, TRUE);
@@ -1485,13 +1494,13 @@ static int translate_event_class(struct fs_sink_comp *fs_sink, struct fs_sink_ct
                                  struct fs_sink_ctf_event_class **out_ec)
 {
     int ret = 0;
-    struct ctx ctx;
+    ctf::sink::TraceIrToCtfIrCtx ctx {fs_sink->logger};
     struct fs_sink_ctf_event_class *ec;
 
     BT_ASSERT(sc);
     BT_ASSERT(ir_ec);
 
-    ctx_init(&ctx, fs_sink);
+    ctx_init(&ctx);
     ec = fs_sink_ctf_event_class_create(sc, ir_ec);
     BT_ASSERT(ec);
     ctx.cur_sc = sc;
@@ -1580,11 +1589,11 @@ static int translate_stream_class(struct fs_sink_comp *fs_sink, struct fs_sink_c
                                   struct fs_sink_ctf_stream_class **out_sc)
 {
     int ret = 0;
-    struct ctx ctx;
+    ctf::sink::TraceIrToCtfIrCtx ctx {fs_sink->logger};
 
     BT_ASSERT(trace);
     BT_ASSERT(ir_sc);
-    ctx_init(&ctx, fs_sink);
+    ctx_init(&ctx);
     *out_sc = fs_sink_ctf_stream_class_create(trace, ir_sc);
     BT_ASSERT(*out_sc);
 
@@ -1688,10 +1697,10 @@ struct fs_sink_ctf_trace *translate_trace_trace_ir_to_ctf_ir(struct fs_sink_comp
         bt_trace_borrow_environment_entry_by_index_const(ir_trace, i, &name, &val);
 
         if (!ist_valid_identifier(name)) {
-            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);
+            BT_CPPLOGE_SPEC(fs_sink->logger,
+                            "Unsupported trace class's environment entry name: "
+                            "name=\"{}\"",
+                            name);
             goto end;
         }
 
@@ -1700,10 +1709,10 @@ struct fs_sink_ctf_trace *translate_trace_trace_ir_to_ctf_ir(struct fs_sink_comp
         case BT_VALUE_TYPE_STRING:
             break;
         default:
-            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(bt_value_get_type(val)));
+            BT_CPPLOGE_SPEC(fs_sink->logger,
+                            "Unsupported trace class's environment entry value type: "
+                            "type={}",
+                            static_cast<bt2::ValueType>(bt_value_get_type(val)));
             goto end;
         }
     }
This page took 0.033819 seconds and 4 git commands to generate.