|
ORE Studio 0.0.4
|
Boost.Log sink backend that prepares logs for database storage. More...
#include <database_sink_backend.hpp>
Inherits basic_sink_backend< boost::log::sinks::synchronized_feeding >.

Public Member Functions | |
| database_sink_backend (std::shared_ptr< domain::resource > resource, database_log_handler handler, const std::string &source_type="test", const std::string &source_name="unit-test") | |
| Constructs the database sink backend. | |
| void | consume (const boost::log::record_view &rec) |
| Processes a Boost.Log record and converts it for database storage. | |
| void | set_session_id (const boost::uuids::uuid &session_id) |
| Sets the session ID for logs produced by this sink. | |
| void | set_account_id (const boost::uuids::uuid &account_id) |
| Sets the account ID for logs produced by this sink. | |
Boost.Log sink backend that prepares logs for database storage.
This sink extracts log information from Boost.Log records and converts them to the telemetry domain model for storage in the database. It's designed to be used primarily for unit testing scenarios where logs need to be captured in the database for inspection and validation.
The sink can be enabled/disabled via configuration and operates independently of other logging sinks (console, file, telemetry export). It accepts a handler function that performs the actual database storage, allowing for flexibility in how the data is persisted.
Usage:
|
explicit |
Constructs the database sink backend.
| resource | The resource describing the entity producing logs. Shared across all log records from this source. |
| handler | Function called for each converted log entry. |
| source_type | Type of source ('client' or 'server', default: 'test'). |
| source_name | Name of the source application (default: 'unit-test'). |
| void consume | ( | const boost::log::record_view & | rec | ) |
Processes a Boost.Log record and converts it for database storage.
This method is called by Boost.Log for each log record that passes the sink's filter. It extracts all relevant attributes and creates a telemetry_log_entry for the handler to store in the database.
| rec | The Boost.Log record view to process. |
| void set_session_id | ( | const boost::uuids::uuid & | session_id | ) |
Sets the session ID for logs produced by this sink.
This is useful for correlating test logs with specific test sessions.
| session_id | The session UUID to associate with logs. |
| void set_account_id | ( | const boost::uuids::uuid & | account_id | ) |
Sets the account ID for logs produced by this sink.
This is useful for associating test logs with specific accounts.
| account_id | The account UUID to associate with logs. |