client-cpp
0.10.0
|
Log subsystem is based on auto-generated classes according to the log schema used during sdk generation.
Kaa library contains default implementation of:
Log storage default implementation persists log records in memory until records aren't uploaded or application restarts.
For example if we have log schema alike:
Which will be converted into:
To create a log record of "ExampleLogRecord" (assuming Kaa client is initialized and started) use:
After this record will be added to the storage and LogCollector automatically will check if after adding this record it should start log uploading.
Log upload will start if call to implementation of kaa::ILogUploadStrategy::isUploadNeeded(const kaa::ILogUploadConfiguration* configuration, const kaa::ILogStorageStatus* status) will return kaa::LogUploadStrategyDecision::UPLOAD decision.
In order to define custom log upload strategy see custom_strategy
C++ client sdk provides ability to create custom log storage by implementing kaa::ILogStorage interface.
Once custom log storage implementation is given it is necessary to provide kaa::ILogStorageStatus implementation which monitors log storage statistics for kaa::ILogUploadStrategy.
Use kaa::Kaa::getClient().getLogCollector().setStorage(ILogStorage * storage) and kaa::Kaa::getClient().getLogCollector().setStorageStatus(ILogStorageStatus * storage) to set up custom log storage.
C++ client sdk provides ability to define custom log upload strategy via implementing kaa::ILogUploadStrategy.
Library will invoke kaa::ILogUploadStrategy::isUploadNeeded(const kaa::ILogUploadConfiguration* configuration, const kaa::ILogStorageStatus* status) method on each log record is being added.
This method must return one of kaa::LogUploadStrategyDecision where:
For example if it is needed to upload each log record immediately method kaa::ILogUploadStrategy::isUploadNeeded(const kaa::ILogUploadConfiguration* configuration, const kaa::ILogStorageStatus* status) should look like:
Set up custom upload strategy by calling
Use kaa::ILogUploadConfiguration to configure log upload parameters.
By default log upload configuration contains 3 parameters: