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

Class BasicConsoleLogger

Base Type

class BasicConsoleLogger : public holoscan::DataLoggerResource

Class for logging information to the console at runtime.

Information on message contents are logging on emit and/or receive.

==Parameters ==

  • serializer : std::shared_ptr<SimpleTextSerializer>

    • Text serialization resource (optional). A SimpleTextSerializer initialized with default parameters will be automatically added if none is provided.

  • log_inputs: bool (optional, default: true)

  • log_outputs: bool (optional, default: true)

  • log_metadata: bool (optional, default: true)

  • log_tensor_data_contents: bool (optional, default: false)

    • Enable logging of the contents of tensors, not just basic description information. The max_elements parameter of the SimpleTextSerialzier provided to serializer can be used to control how many elements are logged.

  • allowlist_patterns: std::vector<std::string> (optional, default: empty vector)

    • Allow only messages matching one of the provided regex patterns. The denylist_patterns parameter is ignored if allowlist_patterns is non-empty. See note below for more details.

  • denylist_patterns: std::vector<std::string> (optional, default: empty vector)

    • Reject any messages matching one of the provided regex patterns. This parameter is ignored if allowlist_patterns is non-empty. See note below for more details.

Note on allowlist/denylist pattern matching:

If allowlist_patterns or denylist_patterns are specified, they are applied to the unique_id assigned to messages by the underlying framework.

In a non-distributed application (without a fragment name), the unique_id for a message will have one of the following forms:

  • 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 (for multi-receivers with N:1 connection)

Public Functions

HOLOSCAN_RESOURCE_FORWARD_ARGS_SUPER (BasicConsoleLogger, DataLoggerResource) BasicConsoleLogger()=default
virtual void setup(ComponentSpec &spec) override

Defines parameters for the logging resource, including the serializer.

Parameters

spec – The component specification.

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.

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

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

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

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.

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