Move to kernel style SPDX license identifiers
[babeltrace.git] / src / plugins / ctf / common / metadata / ctf-meta-validate.c
index 74e02bb36653985d1c5e91c7170191b3441f1b94..10f65da84875b0bd76bd93581646952beb5412c8 100644 (file)
@@ -1,20 +1,13 @@
 /*
- * 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_OUTPUT_LEVEL log_level
+#define BT_COMP_LOG_SELF_COMP (log_cfg->self_comp)
+#define BT_LOG_OUTPUT_LEVEL (log_cfg->log_level)
 #define BT_LOG_TAG "PLUGIN/CTF/META/VALIDATE"
-#include "logging/log.h"
+#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
 int validate_stream_class(struct ctf_stream_class *sc,
-               bt_logging_level log_level)
+               struct meta_log_config *log_cfg)
 {
        int ret = 0;
        struct ctf_field_class_int *int_fc;
@@ -43,7 +37,7 @@ int validate_stream_class(struct ctf_stream_class *sc,
        if (fc) {
                if (fc->type != CTF_FIELD_CLASS_TYPE_INT &&
                                fc->type != CTF_FIELD_CLASS_TYPE_ENUM) {
-                       BT_LOGE_STR("Invalid packet context field class: "
+                       BT_COMP_LOGE_STR("Invalid packet context field class: "
                                "`timestamp_begin` member is not an integer field class.");
                        goto invalid;
                }
@@ -51,7 +45,7 @@ int validate_stream_class(struct ctf_stream_class *sc,
                int_fc = (void *) fc;
 
                if (int_fc->is_signed) {
-                       BT_LOGE_STR("Invalid packet context field class: "
+                       BT_COMP_LOGE_STR("Invalid packet context field class: "
                                "`timestamp_begin` member is signed.");
                        goto invalid;
                }
@@ -62,7 +56,7 @@ int validate_stream_class(struct ctf_stream_class *sc,
        if (fc) {
                if (fc->type != CTF_FIELD_CLASS_TYPE_INT &&
                                fc->type != CTF_FIELD_CLASS_TYPE_ENUM) {
-                       BT_LOGE_STR("Invalid packet context field class: "
+                       BT_COMP_LOGE_STR("Invalid packet context field class: "
                                "`timestamp_end` member is not an integer field class.");
                        goto invalid;
                }
@@ -70,7 +64,7 @@ int validate_stream_class(struct ctf_stream_class *sc,
                int_fc = (void *) fc;
 
                if (int_fc->is_signed) {
-                       BT_LOGE_STR("Invalid packet context field class: "
+                       BT_COMP_LOGE_STR("Invalid packet context field class: "
                                "`timestamp_end` member is signed.");
                        goto invalid;
                }
@@ -81,7 +75,7 @@ int validate_stream_class(struct ctf_stream_class *sc,
        if (fc) {
                if (fc->type != CTF_FIELD_CLASS_TYPE_INT &&
                                fc->type != CTF_FIELD_CLASS_TYPE_ENUM) {
-                       BT_LOGE_STR("Invalid packet context field class: "
+                       BT_COMP_LOGE_STR("Invalid packet context field class: "
                                "`events_discarded` member is not an integer field class.");
                        goto invalid;
                }
@@ -89,7 +83,7 @@ int validate_stream_class(struct ctf_stream_class *sc,
                int_fc = (void *) fc;
 
                if (int_fc->is_signed) {
-                       BT_LOGE_STR("Invalid packet context field class: "
+                       BT_COMP_LOGE_STR("Invalid packet context field class: "
                                "`events_discarded` member is signed.");
                        goto invalid;
                }
@@ -100,7 +94,7 @@ int validate_stream_class(struct ctf_stream_class *sc,
        if (fc) {
                if (fc->type != CTF_FIELD_CLASS_TYPE_INT &&
                                fc->type != CTF_FIELD_CLASS_TYPE_ENUM) {
-                       BT_LOGE_STR("Invalid packet context field class: "
+                       BT_COMP_LOGE_STR("Invalid packet context field class: "
                                "`packet_seq_num` member is not an integer field class.");
                        goto invalid;
                }
@@ -108,7 +102,7 @@ int validate_stream_class(struct ctf_stream_class *sc,
                int_fc = (void *) fc;
 
                if (int_fc->is_signed) {
-                       BT_LOGE_STR("Invalid packet context field class: "
+                       BT_COMP_LOGE_STR("Invalid packet context field class: "
                                "`packet_seq_num` member is signed.");
                        goto invalid;
                }
@@ -119,7 +113,7 @@ int validate_stream_class(struct ctf_stream_class *sc,
        if (fc) {
                if (fc->type != CTF_FIELD_CLASS_TYPE_INT &&
                                fc->type != CTF_FIELD_CLASS_TYPE_ENUM) {
-                       BT_LOGE_STR("Invalid packet context field class: "
+                       BT_COMP_LOGE_STR("Invalid packet context field class: "
                                "`packet_size` member is not an integer field class.");
                        goto invalid;
                }
@@ -127,7 +121,7 @@ int validate_stream_class(struct ctf_stream_class *sc,
                int_fc = (void *) fc;
 
                if (int_fc->is_signed) {
-                       BT_LOGE_STR("Invalid packet context field class: "
+                       BT_COMP_LOGE_STR("Invalid packet context field class: "
                                "`packet_size` member is signed.");
                        goto invalid;
                }
@@ -138,7 +132,7 @@ int validate_stream_class(struct ctf_stream_class *sc,
        if (fc) {
                if (fc->type != CTF_FIELD_CLASS_TYPE_INT &&
                                fc->type != CTF_FIELD_CLASS_TYPE_ENUM) {
-                       BT_LOGE_STR("Invalid packet context field class: "
+                       BT_COMP_LOGE_STR("Invalid packet context field class: "
                                "`content_size` member is not an integer field class.");
                        goto invalid;
                }
@@ -146,7 +140,7 @@ int validate_stream_class(struct ctf_stream_class *sc,
                int_fc = (void *) fc;
 
                if (int_fc->is_signed) {
-                       BT_LOGE_STR("Invalid packet context field class: "
+                       BT_COMP_LOGE_STR("Invalid packet context field class: "
                                "`content_size` member is signed.");
                        goto invalid;
                }
@@ -157,7 +151,7 @@ int validate_stream_class(struct ctf_stream_class *sc,
        if (fc) {
                if (fc->type != CTF_FIELD_CLASS_TYPE_INT &&
                                fc->type != CTF_FIELD_CLASS_TYPE_ENUM) {
-                       BT_LOGE_STR("Invalid event header field class: "
+                       BT_COMP_LOGE_STR("Invalid event header field class: "
                                "`id` member is not an integer field class.");
                        goto invalid;
                }
@@ -165,13 +159,13 @@ int validate_stream_class(struct ctf_stream_class *sc,
                int_fc = (void *) fc;
 
                if (int_fc->is_signed) {
-                       BT_LOGE_STR("Invalid event header field class: "
+                       BT_COMP_LOGE_STR("Invalid event header field class: "
                                "`id` member is signed.");
                        goto invalid;
                }
        } else {
                if (sc->event_classes->len > 1) {
-                       BT_LOGE_STR("Invalid event header field class: "
+                       BT_COMP_LOGE_STR("Invalid event header field class: "
                                "missing `id` member as there's "
                                "more than one event class.");
                        goto invalid;
@@ -189,7 +183,7 @@ end:
 
 BT_HIDDEN
 int ctf_trace_class_validate(struct ctf_trace_class *ctf_tc,
-               bt_logging_level log_level)
+               struct meta_log_config *log_cfg)
 {
        int ret = 0;
        struct ctf_field_class_int *int_fc;
@@ -207,14 +201,14 @@ int ctf_trace_class_validate(struct ctf_trace_class *ctf_tc,
                                        0);
 
                        if (named_fc->fc != fc) {
-                               BT_LOGE_STR("Invalid packet header field class: "
+                               BT_COMP_LOGE_STR("Invalid packet header field class: "
                                        "`magic` member is not the first member.");
                                goto invalid;
                        }
 
                        if (fc->type != CTF_FIELD_CLASS_TYPE_INT &&
                                        fc->type != CTF_FIELD_CLASS_TYPE_ENUM) {
-                               BT_LOGE_STR("Invalid packet header field class: "
+                               BT_COMP_LOGE_STR("Invalid packet header field class: "
                                        "`magic` member is not an integer field class.");
                                goto invalid;
                        }
@@ -222,13 +216,13 @@ int ctf_trace_class_validate(struct ctf_trace_class *ctf_tc,
                        int_fc = (void *) fc;
 
                        if (int_fc->is_signed) {
-                               BT_LOGE_STR("Invalid packet header field class: "
+                               BT_COMP_LOGE_STR("Invalid packet header field class: "
                                        "`magic` member is signed.");
                                goto invalid;
                        }
 
                        if (int_fc->base.size != 32) {
-                               BT_LOGE_STR("Invalid packet header field class: "
+                               BT_COMP_LOGE_STR("Invalid packet header field class: "
                                        "`magic` member is not 32-bit.");
                                goto invalid;
                        }
@@ -239,7 +233,7 @@ int ctf_trace_class_validate(struct ctf_trace_class *ctf_tc,
                if (fc) {
                        if (fc->type != CTF_FIELD_CLASS_TYPE_INT &&
                                        fc->type != CTF_FIELD_CLASS_TYPE_ENUM) {
-                               BT_LOGE_STR("Invalid packet header field class: "
+                               BT_COMP_LOGE_STR("Invalid packet header field class: "
                                        "`stream_id` member is not an integer field class.");
                                goto invalid;
                        }
@@ -247,13 +241,13 @@ int ctf_trace_class_validate(struct ctf_trace_class *ctf_tc,
                        int_fc = (void *) fc;
 
                        if (int_fc->is_signed) {
-                               BT_LOGE_STR("Invalid packet header field class: "
+                               BT_COMP_LOGE_STR("Invalid packet header field class: "
                                        "`stream_id` member is signed.");
                                goto invalid;
                        }
                } else {
                        if (ctf_tc->stream_classes->len > 1) {
-                               BT_LOGE_STR("Invalid packet header field class: "
+                               BT_COMP_LOGE_STR("Invalid packet header field class: "
                                        "missing `stream_id` member as there's "
                                        "more than one stream class.");
                                goto invalid;
@@ -266,7 +260,7 @@ int ctf_trace_class_validate(struct ctf_trace_class *ctf_tc,
                if (fc) {
                        if (fc->type != CTF_FIELD_CLASS_TYPE_INT &&
                                        fc->type != CTF_FIELD_CLASS_TYPE_ENUM) {
-                               BT_LOGE_STR("Invalid packet header field class: "
+                               BT_COMP_LOGE_STR("Invalid packet header field class: "
                                        "`stream_instance_id` member is not an integer field class.");
                                goto invalid;
                        }
@@ -274,7 +268,7 @@ int ctf_trace_class_validate(struct ctf_trace_class *ctf_tc,
                        int_fc = (void *) fc;
 
                        if (int_fc->is_signed) {
-                               BT_LOGE_STR("Invalid packet header field class: "
+                               BT_COMP_LOGE_STR("Invalid packet header field class: "
                                        "`stream_instance_id` member is signed.");
                                goto invalid;
                        }
@@ -286,7 +280,7 @@ int ctf_trace_class_validate(struct ctf_trace_class *ctf_tc,
                        struct ctf_field_class_array *array_fc = (void *) fc;
 
                        if (fc->type != CTF_FIELD_CLASS_TYPE_ARRAY) {
-                               BT_LOGE_STR("Invalid packet header field class: "
+                               BT_COMP_LOGE_STR("Invalid packet header field class: "
                                        "`uuid` member is not an array field class.");
                                goto invalid;
                        }
@@ -294,13 +288,13 @@ int ctf_trace_class_validate(struct ctf_trace_class *ctf_tc,
                        array_fc = (void *) fc;
 
                        if (array_fc->length != 16) {
-                               BT_LOGE_STR("Invalid packet header field class: "
+                               BT_COMP_LOGE_STR("Invalid packet header field class: "
                                        "`uuid` member is not a 16-element array field class.");
                                goto invalid;
                        }
 
                        if (array_fc->base.elem_fc->type != CTF_FIELD_CLASS_TYPE_INT) {
-                               BT_LOGE_STR("Invalid packet header field class: "
+                               BT_COMP_LOGE_STR("Invalid packet header field class: "
                                        "`uuid` member's element field class is not "
                                        "an integer field class.");
                                goto invalid;
@@ -309,21 +303,21 @@ int ctf_trace_class_validate(struct ctf_trace_class *ctf_tc,
                        int_fc = (void *) array_fc->base.elem_fc;
 
                        if (int_fc->is_signed) {
-                               BT_LOGE_STR("Invalid packet header field class: "
+                               BT_COMP_LOGE_STR("Invalid packet header field class: "
                                        "`uuid` member's element field class "
                                        "is a signed integer field class.");
                                goto invalid;
                        }
 
                        if (int_fc->base.size != 8) {
-                               BT_LOGE_STR("Invalid packet header field class: "
+                               BT_COMP_LOGE_STR("Invalid packet header field class: "
                                        "`uuid` member's element field class "
                                        "is not an 8-bit integer field class.");
                                goto invalid;
                        }
 
                        if (int_fc->base.base.alignment != 8) {
-                               BT_LOGE_STR("Invalid packet header field class: "
+                               BT_COMP_LOGE_STR("Invalid packet header field class: "
                                        "`uuid` member's element field class's "
                                        "alignment is not 8.");
                                goto invalid;
@@ -335,9 +329,9 @@ int ctf_trace_class_validate(struct ctf_trace_class *ctf_tc,
                struct ctf_stream_class *sc =
                        ctf_tc->stream_classes->pdata[i];
 
-               ret = validate_stream_class(sc, log_level);
+               ret = validate_stream_class(sc, log_cfg);
                if (ret) {
-                       BT_LOGE("Invalid stream class: sc-id=%" PRIu64, sc->id);
+                       BT_COMP_LOGE("Invalid stream class: sc-id=%" PRIu64, sc->id);
                        goto invalid;
                }
        }
This page took 0.029732 seconds and 4 git commands to generate.