LogIt++
Header-only, macro-first C++ logging library
Loading...
Searching...
No Matches
logit::ILogSubscriber Class Referenceabstract

Optional interface for backends that can notify callers when a record is successfully written. More...

#include <ILogSubscriber.hpp>

Inheritance diagram for logit::ILogSubscriber:
logit::MdbxLogger logit::MemoryLogger

Public Types

using Callback = std::function<void(const LogRecordSnapshot&)>
 

Public Member Functions

virtual ~ILogSubscriber ()=default
 
virtual uint64_t add_log_callback (Callback callback)=0
 Registers a callback to be invoked after each successfully written record.
 
virtual bool remove_log_callback (uint64_t callback_id)=0
 Unregisters a previously added callback.
 

Detailed Description

Optional interface for backends that can notify callers when a record is successfully written.

Callbacks receive a LogRecordSnapshot containing the persisted preview and metadata. String fields inside the snapshot are owned copies and may be stored by value. Callbacks are invoked in registration order after the record has been committed to storage. Implementations must not hold internal locks while invoking callbacks.

Definition at line 21 of file ILogSubscriber.hpp.

Member Typedef Documentation

◆ Callback

using logit::ILogSubscriber::Callback = std::function<void(const LogRecordSnapshot&)>

Definition at line 23 of file ILogSubscriber.hpp.

Constructor & Destructor Documentation

◆ ~ILogSubscriber()

virtual logit::ILogSubscriber::~ILogSubscriber ( )
virtualdefault

Member Function Documentation

◆ add_log_callback()

virtual uint64_t logit::ILogSubscriber::add_log_callback ( Callback callback)
pure virtual

Registers a callback to be invoked after each successfully written record.

Parameters
callbackFunction called with the written LogRecordSnapshot.
Returns
Stable callback id that can be passed to remove_log_callback.

Implemented in logit::MdbxLogger, and logit::MemoryLogger.

◆ remove_log_callback()

virtual bool logit::ILogSubscriber::remove_log_callback ( uint64_t callback_id)
pure virtual

Unregisters a previously added callback.

Removal prevents future dispatch snapshots from including the callback, but cannot cancel an invocation that has already been copied for dispatch.

Parameters
callback_idId returned by add_log_callback.
Returns
True if the callback existed and was removed.

Implemented in logit::MdbxLogger, and logit::MemoryLogger.


The documentation for this class was generated from the following file: