What can I help you with?
NVIDIA Holoscan SDK v3.4.0

Class DataLoggerResource

Base Types

Derived Type

class DataLoggerResource : public holoscan::DataLogger, public holoscan::Resource

Subclassed by holoscan::data_loggers::BasicConsoleLogger

Public Functions

template<typename ArgT, typename ...ArgsT, typename = std::enable_if_t<!std::is_base_of_v<::holoscan::Resource, std::decay_t<ArgT>> && (std::is_same_v<::holoscan::Arg, std::decay_t<ArgT>> || std::is_same_v<::holoscan::ArgList, std::decay_t<ArgT>>)>>
inline explicit DataLoggerResource(ArgT &&arg, ArgsT&&... args)
DataLoggerResource() = default
~DataLoggerResource() override = default
virtual void setup(ComponentSpec &spec) override

Defines parameters for the logging resource, including the serializer.

Parameters

spec – The component specification.

virtual 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

Logs a message.

The unique_id for the message will have the form:

  • operator_name.port_name

  • operator_name.port_name:index (for multi-receivers with N:1 connection)

For distributed applications, the fragment name will also appear in the unique id:

  • fragment_name.operator_name.port_name

  • fragment_name.operator_name.port_name:index

Parameters
  • data – The data to log, passed as std::any.

  • unique_id – A unique identifier for the message.

  • acquisition_timestamp – Timestamp when the data was acquired (-1 if unknown).

  • metadata – Associated metadata dictionary for the message.

  • io_type – The type of I/O port (kInput or kOutput).

Returns

true if logging (including serialization and sending) was successful, false otherwise.

virtual 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

Logs a Tensor with optional data content logging.

This specialized method allows efficient logging of tensor metadata without the overhead of logging large tensor data arrays when only header information is needed.

The unique_id for the message will have the form:

  • operator_name.port_name

  • operator_name.port_name:index (for multi-receivers with N:1 connection)

For distributed applications, the fragment name will also appear in the unique id:

  • fragment_name.operator_name.port_name

  • fragment_name.operator_name.port_name:index

Parameters
  • tensor – The Tensor to log.

  • unique_id – A unique identifier for the message.

  • acquisition_timestamp – Timestamp when the data was acquired (-1 if unknown).

  • metadata – Associated metadata dictionary for the message.

  • io_type – The type of I/O port (kInput or kOutput).

Returns

true if logging was successful, false otherwise.

virtual 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

Logs a TensorMap with optional data content logging.

This specialized method allows efficient logging of tensor map metadata without the overhead of logging large tensor data arrays when only header information is needed.

The unique_id for the message will have the form:

  • operator_name.port_name

  • operator_name.port_name:index (for multi-receivers with N:1 connection)

For distributed applications, the fragment name will also appear in the unique id:

  • fragment_name.operator_name.port_name

  • fragment_name.operator_name.port_name:index

Parameters
  • tensor_map – The TensorMap to log.

  • unique_id – A unique identifier for the message.

  • acquisition_timestamp – Timestamp when the data was acquired (-1 if unknown).

  • metadata – Associated metadata dictionary for the message.

  • io_type – The type of I/O port (kInput or kOutput).

Returns

true if logging was successful, false otherwise.

bool should_log_message(const std::string &unique_id) const

Checks if a message with the given unique_id should be logged based on allowlist/denylist patterns.

This utility function implements the filtering logic:

  • If allowlist patterns are specified and unique_id matches any allowlist pattern: log it

  • If allowlist patterns are specified and unique_id doesn’t match any allowlist pattern: don’t log it

  • If no allowlist patterns are specified, check denylist:

    • If unique_id matches any denylist pattern: don’t log it

    • Otherwise: log it

Parameters

unique_id – The unique identifier to check against patterns.

Returns

true if the message should be logged, false otherwise.

inline virtual bool should_log_output() const override

Checks if the logger should log output ports.

If False, the data logger will not be applied during op_input.emit() calls from Operator::compute.

Returns

true if the logger should log output ports, false otherwise.

inline virtual bool should_log_input() const override

Checks if the logger should log input ports.

If False, the data logger will not be applied during op_input.receive() calls from Operator::compute.

Returns

true if the logger should log input ports, false otherwise.

inline bool should_log_metadata() const

Checks if the logger should log metadata.

If False, the data logger will not log metadata for each operator.

Returns

true if the logger should log metadata, false otherwise.

inline bool should_log_tensor_data_content() const

Checks if the logger should log tensor data content.

If False, only tensor header information will be logged, not the actual data arrays. When true, the full tensor data is also logged.

Returns

true if the logger should log tensor data content, false otherwise.

virtual int64_t get_timestamp() const

Get the current timestamp for logging operations.

This method is called internally by the logging functions to obtain timestamps for emit_timestamp (when io_type==IOSpec::IOType::kOutput) or receive_timestamp (when io_type==IOSpec::IOType::kInput). The default implementation provides high-resolution timestamps in microseconds since epoch. Implementations can override this to provide custom timing mechanisms as appropriate.

Returns

Current timestamp in microseconds since epoch, or -1 if not available.

virtual void initialize() override

Initialize the component.

This method is called only once when the component is created for the first time, and use of light-weight initialization.

Protected Attributes

Parameter<bool> log_outputs_
Parameter<bool> log_inputs_
Parameter<bool> log_tensor_data_content_
Parameter<bool> log_metadata_
Parameter<std::vector<std::string>> allowlist_patterns_
Parameter<std::vector<std::string>> denylist_patterns_

Previous Class DataLogger
Next Class DefaultFragmentService
© Copyright 2022-2025, NVIDIA. Last updated on Jul 1, 2025.