> This page is for version 3.0 (Latest) (default).
> For other versions, use one of these documentation indexes:
> - 3.0 (Latest) (default): https://docs.nvidia.com/holoscan/sensor-bridge/3-0/llms.txt
> - 2.7: https://docs.nvidia.com/holoscan/sensor-bridge/2-7/llms.txt
> - Archives: https://docs.nvidia.com/holoscan/sensor-bridge/archives/llms.txt

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/holoscan/sensor-bridge/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/holoscan/sensor-bridge/_mcp/server.

# hololink::module::LoggingInterfaceV1

> Application-wide sink for log messages.

Application-wide sink for log messages.

The host application implements this interface (see logging_impl.cpp) and publishes it to loaded modules; this way all the loaded modules send their logging messages to the same application receiver.

Code within this framework normally logs through the `HSB_LOG_TRACE`, `HSB_LOG_DEBUG`, `HSB_LOG_INFO`, `HSB_LOG_WARN` and `HSB_LOG_ERROR` macros, which compare against level() before formatting the message and then call log() with the call site's file, line and function.

```cpp showLineNumbers={false}
#include <hololink/module/logging.hpp>
```

**Inherits from:** `hololink::module::Service< LoggingInterfaceV1 >` (public)

---

## Methods

### level \[#level]

```cpp showLineNumbers={false}
virtual LogLevel hololink::module::LoggingInterfaceV1::level() const
```

Returns the current setting for log level filtering.

A message should be sent to log() only if its level is greater than or equal to this value. Callers check this before building the message so that disabled log statements cost no formatting work. log() does not itself discard messages below this threshold.

**Returns:** The current threshold.

### log \[#log]

```cpp showLineNumbers={false}
virtual void hololink::module::LoggingInterfaceV1::log(
    LogLevel level,
    const char *file,
    unsigned line,
    const char *function,
    const char *message
)
```

Deliver one fully formatted log message to the sink.

The sink decorates the message with its own metadata (for example severity, timestamp and thread) and writes it to its destination. This may be called concurrently from multiple threads. All pointer arguments must be non-null, NUL-terminated strings, and are only valid for the duration of the call.

**Parameters**

**`level`** `LogLevel`

Severity of the message.

---

**`file`** `const char *`

Source file of the call site.

---

**`line`** `unsigned`

Line number of the call site.

---

**`function`** `const char *`

Name of the function containing the call site.

---

**`message`** `const char *`

The text to log; no further formatting is applied.

---

### module \[#module]

```cpp showLineNumbers={false}
std::shared_ptr<Module> hololink::module::ServiceBase::module() const
```

The [Module](module) that this service was published from.

The service holds no strong reference to its [Module](module), so this does not extend the [Module](module)'s lifetime.

**Returns:** The owning [Module](module), or an empty pointer if the service has not been published or its [Module](module) no longer exists.

---

## Static methods

### get_service \[#getservice]

#### Fetch the process-wide logger from a module

```cpp showLineNumbers={false}
static std::shared_ptr<LoggingInterfaceV1> hololink::module::LoggingInterfaceV1::get_service(
    std::shared_ptr<Module> module,
    bool allow_null = false
)
```

Fetch the process-wide logger from a module.

There is only one logger, so no instance identifier is needed.

**Returns:** A shared pointer to the logger.

**Parameters**

**`module`** `std::shared_ptr<Module>`

The module to query.

---

**`allow_null`** `bool` — default: false

If `false` (the default), throws std::runtime_error when the module doesn't provide a logger (or `module` is null). If `true`, returns `nullptr` instead.

---

#### Overload 2

```cpp showLineNumbers={false}
static std::shared_ptr<LoggingInterfaceV1> hololink::module::Service<LoggingInterfaceV1>::get_service(
    std::shared_ptr<Module> module,
    const char *instance_id,
    bool allow_null = false
)
```

Type-safe way to fetch a std::shared_ptr to an instance of \<Derived> from a [Module](module).

Note that [Module](module) usually caches instances, it's likely that calls to get_service with the same locator_id will return pointers to the same implementation object.

**Returns:** A shared pointer to the service instance.

**Parameters**

**`module`** `std::shared_ptr<Module>`

Is the shared object that owns the instance we wish to fetch

---

**`instance_id`** `const char *`

Names the specific object, usually expressed as a set of "name=value;..." pairs, as defined by the implementations themselves. This name is normally fetched by calling `Derived::locator_id(enumeration_metadata)`.

---

**`allow_null`** `bool` — default: false

The default value of `false` causes this routine to throw a std::runtime_error if the service cannot be found within the module; this would be expected to terminate the calling program. If the application wants to handle the error, pass in `true` here and get_service will return `nullptr` when this module doesn't provide the requested service.

---

### for_each_type_id \[#foreachtypeid]

```cpp showLineNumbers={false}
static bool hololink::module::Service<LoggingInterfaceV1>::for_each_type_id(
    Callback &&cb
)
```

Iterate over every type_id supported by this instance.

The callback signature is `bool(const char*)` — returning false halts the walk; true continues. Iteration is depth-first, so you'll see the most specific implementation types first.