NVIDIA Holoscan SDK v3.5.0

Class BasicConsoleLogger

Base Type

Derived 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)

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

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)

The pattern matching logic is as follows:

  • If denylist patterns is not empty and there is a match, do not log it.

  • Next check if allowlist_patterns is empty:

    • If yes, return true (allow everything)

    • If no, return true only if there is a match to at least one of the specified patterns.

Subclassed by holoscan::data_loggers::GXFConsoleLogger

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(const std::any &data, 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 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.

virtual bool log_backend_specific(const std::any &data, 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 backend-specific data types.

This method is called for logging backend-specific data types (intended for use with backends that have separate emit/receive codepaths for backend-specific types). The data parameter is kept as std::any here to avoid making the base interface specific to a particular backend, but a backend-specific concrete implementation should be provided as needed via run-time type checking.

A concrete example of a backend-specific type is the GXF Entity type which is a heterogeneous collection of components. An implementation of this method for GXF entities is provided in the concrete implementation of the GXFConsoleLogger.

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 backend-specific 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 was successful, false if backend-specific logging is not supported.

Previous Class AsyncConsoleLogger
Next Class GXFConsoleLogger
© Copyright 2022-2025, NVIDIA. Last updated on Aug 1, 2025.