NVIDIA Holoscan SDK v3.4.0

Program Listing for File data_logger.hpp

Return to documentation for file (include/holoscan/core/resources/data_logger.hpp)

Copy
Copied!
            

/* * SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef HOLOSCAN_CORE_RESOURCES_DATA_LOGGER_HPP #define HOLOSCAN_CORE_RESOURCES_DATA_LOGGER_HPP #include <any> #include <cstdint> #include <memory> // For std::shared_ptr in parameters #include <regex> #include <string> #include <vector> #include "../component_spec.hpp" #include "../data_logger.hpp" #include "../resource.hpp" namespace holoscan { class MetadataDictionary; // forward declaration class Tensor; // forward declaration class TensorMap; // forward declaration class DataLoggerResource : public DataLogger, public Resource { public: HOLOSCAN_RESOURCE_FORWARD_ARGS_SUPER(DataLoggerResource, Resource) // Forward arguments to Resource DataLoggerResource() = default; ~DataLoggerResource() override = default; void setup(ComponentSpec& spec) override; // initialize() is inherited from Resource and should be overridden by concrete loggers. bool log_data(std::any data, const std::string& unique_id, int64_t acquisition_timestamp = -1, std::shared_ptr<MetadataDictionary> metadata = nullptr, IOSpec::IOType io_type = IOSpec::IOType::kOutput) override = 0; bool log_tensor_data(const std::shared_ptr<Tensor>& tensor, const std::string& unique_id, int64_t acquisition_timestamp = -1, const std::shared_ptr<MetadataDictionary>& metadata = nullptr, IOSpec::IOType io_type = IOSpec::IOType::kOutput) override = 0; bool log_tensormap_data(const TensorMap& tensor_map, const std::string& unique_id, int64_t acquisition_timestamp = -1, const std::shared_ptr<MetadataDictionary>& metadata = nullptr, IOSpec::IOType io_type = IOSpec::IOType::kOutput) override = 0; bool should_log_message(const std::string& unique_id) const; bool should_log_output() const override { return log_outputs_.get(); } bool should_log_input() const override { return log_inputs_.get(); } bool should_log_metadata() const { return log_metadata_.get(); } bool should_log_tensor_data_content() const { return log_tensor_data_content_.get(); } virtual int64_t get_timestamp() const; void initialize() override; protected: // TODO(grelee): should we add a standard serializer interface here? // Parameter<std::shared_ptr<DataLoggerSerializer>> serializer_; Parameter<bool> log_outputs_; Parameter<bool> log_inputs_; Parameter<bool> log_tensor_data_content_; Parameter<bool> log_metadata_; // Filtering parameters Parameter<std::vector<std::string>> allowlist_patterns_; Parameter<std::vector<std::string>> denylist_patterns_; private: // Compiled regex patterns for efficient matching std::vector<std::regex> compiled_allowlist_patterns_; std::vector<std::regex> compiled_denylist_patterns_; bool patterns_compiled_ = false; void compile_patterns(); }; } // namespace holoscan #endif/* HOLOSCAN_CORE_RESOURCES_DATA_LOGGER_HPP */

© Copyright 2022-2025, NVIDIA. Last updated on Jul 1, 2025.