omni::structuredlog::IStructuredLogExtraFields
Defined in omni/structuredlog/IStructuredLogExtraFields.h
-
class IStructuredLogExtraFields : public omni::core::Generated<omni::structuredlog::IStructuredLogExtraFields_abi>
Interface to manage extra CloudEvent fields to be included in each emitted message.
This allows for fields to be added and removed as needed. It also allows existing registered fields to be enumerated at any given time. An extra field is a key/value pair that is included at the top level of the JSON object for each message that follows. Only string values are allowed for each key.
Public Functions
-
inline bool setValue(const char *fieldName, const char *value, omni::structuredlog::ExtraFieldFlags flags) noexcept
Adds, modifies, or removes an extra field key/value pair.
Remark
This adds, modifies, or removes a registered extra field and value. Any extra fields that are registered at the time a message is emitted will be added to the message on output. At least for the first version of this interface it is expected that extra fields be largely static.
- Thread Safety
This call is thread safe.
- Parameters
fieldName – [in] The name of the field to add, modify or remove. This may not be
nullptr
or and empty string. The field name must only contain alphabetic, numeric, or underscore ASCII characters. Any characters outside these will cause the field to not be updated. Further, this may not be one of the reserved CloudEvent field names such as “specversion”, “data”, “time”, “source”, “session”, “dataschema”, “type”, or “subject”.value – [in] The new value to set for the requested extra field. This may be
nullptr
to indicate that the named field should be removed. The value string may include any characters, but should be limited to a small number of characters (ideally less than 64 characters).flags – [in] Flags to control how the new value is added, modified, or removed. Currently no flags are defined. This must be set to omni::structuredlog::fExtraFieldFlagNone.
- Returns
true
if the requested extra field is successfully added, modified, or removed. Returnsfalse
if an invalid field name is given, or the operation could not be completed for any reason.
-
inline void *cast(omni::core::TypeId id) noexcept
Returns a pointer to the interface defined by the given type id if this object implements the type id’s interface.
Objects can support multiple interfaces, even interfaces that are in different inheritance chains.
The returned object will have omni::core::IObject::acquire() called on it before it is returned, meaning it is up to the caller to call omni::core::IObject::release() on the returned pointer.
The returned pointer can be safely
reinterpret_cast<>
to the type id’s C++ class. For example, “omni.windowing.IWindow” can be cast toomni::windowing::IWindow
.Do not directly use this method, rather use a wrapper function like omni::core::cast() or omni::core::ObjectPtr::as().
- Thread Safety
This method is thread safe.
-
inline void acquire() noexcept
Increments the object’s reference count.
Objects may have multiple reference counts (e.g. one per interface implemented). As such, it is important that you call omni::core::IObject::release() on the same pointer from which you called omni::core::IObject::acquire().
Do not directly use this method, rather use omni::core::ObjectPtr, which will manage calling omni::core::IObject::acquire() and omni::core::IObject::release() for you.
- Thread Safety
This method is thread safe.
-
inline void release() noexcept
Decrements the objects reference count.
Most implementations will destroy the object if the reference count reaches 0 (though this is not a requirement).
Objects may have multiple reference counts (e.g. one per interface implemented). As such, it is important that you call omni::core::IObject::release() on the same pointer from which you called omni::core::IObject::acquire().
Do not directly use this method, rather use omni::core::ObjectPtr, which will manage calling omni::core::IObject::acquire() and omni::core::IObject::release() for you.
- Thread Safety
This method is thread safe.
Protected Functions
-
virtual bool setValue_abi(const char *fieldName, const char *value, ExtraFieldFlags flags) noexcept = 0
Adds, modifies, or removes an extra field key/value pair.
Remark
This adds, modifies, or removes a registered extra field and value. Any extra fields that are registered at the time a message is emitted will be added to the message on output. At least for the first version of this interface it is expected that extra fields be largely static.
- Thread Safety
This call is thread safe.
- Parameters
fieldName – [in] The name of the field to add, modify or remove. This may not be
nullptr
or and empty string. The field name must only contain alphabetic, numeric, or underscore ASCII characters. Any characters outside these will cause the field to not be updated. Further, this may not be one of the reserved CloudEvent field names such as “specversion”, “data”, “time”, “source”, “session”, “dataschema”, “type”, or “subject”.value – [in] The new value to set for the requested extra field. This may be
nullptr
to indicate that the named field should be removed. The value string may include any characters, but should be limited to a small number of characters (ideally less than 64 characters).flags – [in] Flags to control how the new value is added, modified, or removed. Currently no flags are defined. This must be set to omni::structuredlog::fExtraFieldFlagNone.
- Returns
true
if the requested extra field is successfully added, modified, or removed. Returnsfalse
if an invalid field name is given, or the operation could not be completed for any reason.
-
virtual void *cast_abi(TypeId id) noexcept = 0
Returns a pointer to the interface defined by the given type id if this object implements the type id’s interface.
Objects can support multiple interfaces, even interfaces that are in different inheritance chains.
The returned object will have omni::core::IObject::acquire() called on it before it is returned, meaning it is up to the caller to call omni::core::IObject::release() on the returned pointer.
The returned pointer can be safely
reinterpret_cast<>
to the type id’s C++ class. For example, “omni.windowing.IWindow” can be cast toomni::windowing::IWindow
.Do not directly use this method, rather use a wrapper function like omni::core::cast() or omni::core::ObjectPtr::as().
- Thread Safety
This method is thread safe.
-
virtual void acquire_abi() noexcept = 0
Increments the object’s reference count.
Objects may have multiple reference counts (e.g. one per interface implemented). As such, it is important that you call omni::core::IObject::release() on the same pointer from which you called omni::core::IObject::acquire().
Do not directly use this method, rather use omni::core::ObjectPtr, which will manage calling omni::core::IObject::acquire() and omni::core::IObject::release() for you.
- Thread Safety
This method is thread safe.
-
virtual void release_abi() noexcept = 0
Decrements the objects reference count.
Most implementations will destroy the object if the reference count reaches 0 (though this is not a requirement).
Objects may have multiple reference counts (e.g. one per interface implemented). As such, it is important that you call omni::core::IObject::release() on the same pointer from which you called omni::core::IObject::acquire().
Do not directly use this method, rather use omni::core::ObjectPtr, which will manage calling omni::core::IObject::acquire() and omni::core::IObject::release() for you.
- Thread Safety
This method is thread safe.
-
inline bool setValue(const char *fieldName, const char *value, omni::structuredlog::ExtraFieldFlags flags) noexcept