ctf: use `bt2c::Logger` throughout `src.ctf.fs`, `src.ctf.lttng-live`
[babeltrace.git] / src / plugins / ctf / common / src / metadata / tsdl / ctf-meta-update-default-clock-classes.cpp
index ab10dd4fa173a31a8d8571c0da3edd0743bff692..cd9acdf2c225e12095ac85f44bd082aa2c13d0ed 100644 (file)
@@ -4,20 +4,15 @@
  * Copyright 2018 Philippe Proulx <pproulx@efficios.com>
  */
 
-#include <inttypes.h>
-#include <string.h>
+#include <babeltrace2/babeltrace.h>
 
-#define BT_COMP_LOG_SELF_COMP       (log_cfg->self_comp)
-#define BT_COMP_LOG_SELF_COMP_CLASS (log_cfg->self_comp_class)
-#define BT_LOG_OUTPUT_LEVEL         (log_cfg->log_level)
-#define BT_LOG_TAG                  "PLUGIN/CTF/META/UPDATE-DEF-CC"
-#include "logging.hpp"
+#include "cpp-common/bt2c/logging.hpp"
 
 #include "ctf-meta-visitors.hpp"
 
 static inline int find_mapped_clock_class(struct ctf_field_class *fc,
                                           struct ctf_clock_class **clock_class,
-                                          struct meta_log_config *log_cfg)
+                                          const bt2c::Logger& logger)
 {
     int ret = 0;
     uint64_t i;
@@ -34,11 +29,12 @@ static inline int find_mapped_clock_class(struct ctf_field_class *fc,
 
         if (int_fc->mapped_clock_class) {
             if (*clock_class && *clock_class != int_fc->mapped_clock_class) {
-                _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Stream class contains more than one "
-                                                         "clock class: expected-cc-name=\"%s\", "
-                                                         "other-cc-name=\"%s\"",
-                                                         (*clock_class)->name->str,
-                                                         int_fc->mapped_clock_class->name->str);
+                BT_CPPLOGE_APPEND_CAUSE_SPEC(logger,
+                                             "Stream class contains more than one "
+                                             "clock class: expected-cc-name=\"{}\", "
+                                             "other-cc-name=\"{}\"",
+                                             (*clock_class)->name->str,
+                                             int_fc->mapped_clock_class->name->str);
                 ret = -1;
                 goto end;
             }
@@ -56,7 +52,7 @@ static inline int find_mapped_clock_class(struct ctf_field_class *fc,
             struct ctf_named_field_class *named_fc =
                 ctf_field_class_struct_borrow_member_by_index(struct_fc, i);
 
-            ret = find_mapped_clock_class(named_fc->fc, clock_class, log_cfg);
+            ret = find_mapped_clock_class(named_fc->fc, clock_class, logger);
             if (ret) {
                 goto end;
             }
@@ -72,7 +68,7 @@ static inline int find_mapped_clock_class(struct ctf_field_class *fc,
             struct ctf_named_field_class *named_fc =
                 ctf_field_class_variant_borrow_option_by_index(var_fc, i);
 
-            ret = find_mapped_clock_class(named_fc->fc, clock_class, log_cfg);
+            ret = find_mapped_clock_class(named_fc->fc, clock_class, logger);
             if (ret) {
                 goto end;
             }
@@ -85,7 +81,7 @@ static inline int find_mapped_clock_class(struct ctf_field_class *fc,
     {
         struct ctf_field_class_array_base *array_fc = ctf_field_class_as_array_base(fc);
 
-        ret = find_mapped_clock_class(array_fc->elem_fc, clock_class, log_cfg);
+        ret = find_mapped_clock_class(array_fc->elem_fc, clock_class, logger);
         if (ret) {
             goto end;
         }
@@ -101,23 +97,23 @@ end:
 }
 
 static inline int update_stream_class_default_clock_class(struct ctf_stream_class *stream_class,
-                                                          struct meta_log_config *log_cfg)
+                                                          const bt2c::Logger& logger)
 {
     int ret = 0;
     struct ctf_clock_class *clock_class = stream_class->default_clock_class;
     uint64_t i;
 
-    ret = find_mapped_clock_class(stream_class->packet_context_fc, &clock_class, log_cfg);
+    ret = find_mapped_clock_class(stream_class->packet_context_fc, &clock_class, logger);
     if (ret) {
         goto end;
     }
 
-    ret = find_mapped_clock_class(stream_class->event_header_fc, &clock_class, log_cfg);
+    ret = find_mapped_clock_class(stream_class->event_header_fc, &clock_class, logger);
     if (ret) {
         goto end;
     }
 
-    ret = find_mapped_clock_class(stream_class->event_common_context_fc, &clock_class, log_cfg);
+    ret = find_mapped_clock_class(stream_class->event_common_context_fc, &clock_class, logger);
     if (ret) {
         goto end;
     }
@@ -126,12 +122,12 @@ static inline int update_stream_class_default_clock_class(struct ctf_stream_clas
         struct ctf_event_class *event_class =
             (ctf_event_class *) stream_class->event_classes->pdata[i];
 
-        ret = find_mapped_clock_class(event_class->spec_context_fc, &clock_class, log_cfg);
+        ret = find_mapped_clock_class(event_class->spec_context_fc, &clock_class, logger);
         if (ret) {
             goto end;
         }
 
-        ret = find_mapped_clock_class(event_class->payload_fc, &clock_class, log_cfg);
+        ret = find_mapped_clock_class(event_class->payload_fc, &clock_class, logger);
         if (ret) {
             goto end;
         }
@@ -146,13 +142,14 @@ end:
 }
 
 int ctf_trace_class_update_default_clock_classes(struct ctf_trace_class *ctf_tc,
-                                                 struct meta_log_config *log_cfg)
+                                                 const bt2c::Logger& parentLogger)
 {
     uint64_t i;
     int ret = 0;
     struct ctf_clock_class *clock_class = NULL;
+    bt2c::Logger logger {parentLogger, "PLUGIN/CTF/META/UPDATE-DEF-CC"};
 
-    ret = find_mapped_clock_class(ctf_tc->packet_header_fc, &clock_class, log_cfg);
+    ret = find_mapped_clock_class(ctf_tc->packet_header_fc, &clock_class, logger);
     if (ret) {
         goto end;
     }
@@ -166,11 +163,12 @@ int ctf_trace_class_update_default_clock_classes(struct ctf_trace_class *ctf_tc,
         struct ctf_stream_class *sc = (ctf_stream_class *) ctf_tc->stream_classes->pdata[i];
 
         ret = update_stream_class_default_clock_class(
-            (ctf_stream_class *) ctf_tc->stream_classes->pdata[i], log_cfg);
+            (ctf_stream_class *) ctf_tc->stream_classes->pdata[i], logger);
         if (ret) {
-            _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Stream class contains more than one "
-                                                     "clock class: stream-class-id=%" PRIu64,
-                                                     sc->id);
+            BT_CPPLOGE_APPEND_CAUSE_SPEC(logger,
+                                         "Stream class contains more than one "
+                                         "clock class: stream-class-id={}",
+                                         sc->id);
             goto end;
         }
     }
This page took 0.024855 seconds and 4 git commands to generate.