ctf: append error causes when returning errors
[babeltrace.git] / src / plugins / ctf / common / metadata / ctf-meta-update-default-clock-classes.c
index 41ca6b0301e68027f08a062e43c2d57e1bd10f02..f6c19b1a4e073e48c14f92c595b19d05d92a84fa 100644 (file)
@@ -1,19 +1,14 @@
 /*
- * Copyright 2018 - Philippe Proulx <pproulx@efficios.com>
+ * SPDX-License-Identifier: MIT
  *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
+ * Copyright 2018 Philippe Proulx <pproulx@efficios.com>
  */
 
-#define BT_LOG_TAG "PLUGIN-CTF-METADATA-META-UPDATE-DEF-CC"
-#include "logging.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/comp-logging.h"
 
 #include <babeltrace2/babeltrace.h>
 #include "common/macros.h"
 #include <inttypes.h>
 
 #include "ctf-meta-visitors.h"
+#include "logging.h"
 
 static inline
 int find_mapped_clock_class(struct ctf_field_class *fc,
-               struct ctf_clock_class **clock_class)
+               struct ctf_clock_class **clock_class,
+               struct meta_log_config *log_cfg)
 {
        int ret = 0;
        uint64_t i;
@@ -45,7 +42,7 @@ 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_LOGE("Stream class contains more than one "
+                               _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,
@@ -69,7 +66,7 @@ int find_mapped_clock_class(struct ctf_field_class *fc,
                                        struct_fc, i);
 
                        ret = find_mapped_clock_class(named_fc->fc,
-                               clock_class);
+                               clock_class, log_cfg);
                        if (ret) {
                                goto end;
                        }
@@ -87,7 +84,7 @@ int find_mapped_clock_class(struct ctf_field_class *fc,
                                        var_fc, i);
 
                        ret = find_mapped_clock_class(named_fc->fc,
-                               clock_class);
+                               clock_class, log_cfg);
                        if (ret) {
                                goto end;
                        }
@@ -100,7 +97,8 @@ int find_mapped_clock_class(struct ctf_field_class *fc,
        {
                struct ctf_field_class_array_base *array_fc = (void *) fc;
 
-               ret = find_mapped_clock_class(array_fc->elem_fc, clock_class);
+               ret = find_mapped_clock_class(array_fc->elem_fc, clock_class,
+                       log_cfg);
                if (ret) {
                        goto end;
                }
@@ -117,7 +115,8 @@ end:
 
 static inline
 int update_stream_class_default_clock_class(
-               struct ctf_stream_class *stream_class)
+               struct ctf_stream_class *stream_class,
+               struct meta_log_config *log_cfg)
 {
        int ret = 0;
        struct ctf_clock_class *clock_class =
@@ -125,19 +124,19 @@ int update_stream_class_default_clock_class(
        uint64_t i;
 
        ret = find_mapped_clock_class(stream_class->packet_context_fc,
-               &clock_class);
+               &clock_class, log_cfg);
        if (ret) {
                goto end;
        }
 
        ret = find_mapped_clock_class(stream_class->event_header_fc,
-               &clock_class);
+               &clock_class, log_cfg);
        if (ret) {
                goto end;
        }
 
        ret = find_mapped_clock_class(stream_class->event_common_context_fc,
-               &clock_class);
+               &clock_class, log_cfg);
        if (ret) {
                goto end;
        }
@@ -147,13 +146,13 @@ int update_stream_class_default_clock_class(
                        stream_class->event_classes->pdata[i];
 
                ret = find_mapped_clock_class(event_class->spec_context_fc,
-                       &clock_class);
+                       &clock_class, log_cfg);
                if (ret) {
                        goto end;
                }
 
                ret = find_mapped_clock_class(event_class->payload_fc,
-                       &clock_class);
+                       &clock_class, log_cfg);
                if (ret) {
                        goto end;
                }
@@ -168,13 +167,15 @@ end:
 }
 
 BT_HIDDEN
-int ctf_trace_class_update_default_clock_classes(struct ctf_trace_class *ctf_tc)
+int ctf_trace_class_update_default_clock_classes(struct ctf_trace_class *ctf_tc,
+               struct meta_log_config *log_cfg)
 {
        uint64_t i;
        int ret = 0;
        struct ctf_clock_class *clock_class = NULL;
 
-       ret = find_mapped_clock_class(ctf_tc->packet_header_fc, &clock_class);
+       ret = find_mapped_clock_class(ctf_tc->packet_header_fc, &clock_class,
+               log_cfg);
        if (ret) {
                goto end;
        }
@@ -189,9 +190,9 @@ int ctf_trace_class_update_default_clock_classes(struct ctf_trace_class *ctf_tc)
                        ctf_tc->stream_classes->pdata[i];
 
                ret = update_stream_class_default_clock_class(
-                       ctf_tc->stream_classes->pdata[i]);
+                       ctf_tc->stream_classes->pdata[i], log_cfg);
                if (ret) {
-                       BT_LOGE("Stream class contains more than one "
+                       _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Stream class contains more than one "
                                "clock class: stream-class-id=%" PRIu64,
                                sc->id);
                        goto end;
This page took 0.026924 seconds and 4 git commands to generate.