Logger#

Fully qualified name: omni::observability::Logger

Defined in omni/observability/ObservabilityDebug.h

class Logger : public omni::observability::RefCountedObject#

Logger base class.

Host apps should inherit from and implement this class to be able to allow them to be able to receive internal log messages from the omni.observability.core library. The implemented logger object can be registered with the library with a call to omni::observability::IObservabilityProvider::registerLogger(). The caller can release its local reference to the object immediately after registering it if needed. The module that holds the code for the logger must remain loaded as long as the logger is registered with the omni.observability.core library. The host app can unregister a logger using omni::observability::IObservabilityProvider::unregisterLogger() when log messages are no longer needed.

Subclassed by omni::observability::SilentLogger

Public Functions

virtual void handleMsg(
const LogMetadata &metadata,
carb::cpp::string_view messageText,
) = 0#

Receives internal log messages from the core library.

Remark

This allows a host app to observe log messages that report the status of the omni.observability.core library itself. These messages are intended to help with debugging and should only be enabled in debugging situations either through an app setting or in a debug build. This implementation may process the log message in any way it pleases including re-emitting the message through its own logging system that ends up going back through the OTel API as an OTLP log message.

Note

If a log message is re-emitted in a way that goes back through the core library, any other internal log message that is recursively emitted from the core library will be silenced to avoid infinite recursion.

Parameters:
  • metadata[in] The metadata associated with the log message.

  • messageText[in] The message text itself.

inline void addRef()#

Adds a reference to this object.

Remark

This adds a single new reference to this object. If the reference count is greater than zero, the object is protected from being destroyed regardless of what order references are released. Each call to this must be balanced with a call to release() when this object is no longer needed.

inline void release()#

Releases a reference to this object and potentially destroys it.

Remark

This releases a single reference to this object. If the reference count reaches zero, the object wlil be destroyed immediately. This should only be called to balance a previous call to addRef(). It is the caller’s responsibility to ensure that all references to this object are successfully released. Failure to release all references will result in this object being leaked.

Protected Attributes

std::atomic<int32_t> m_refCount = 1#

The current reference count on this object.