Kaa client C SDK
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Data Structures | Functions
ext_log_storage.h File Reference

External log storage interface used by Kaa data collection subsystem to temporarily store the logs before sending them to Operations server. More...

#include <stddef.h>
#include "kaa_error.h"

Go to the source code of this file.

Data Structures

struct  kaa_log_record_t
 Wrapper for a serialized log entry. More...
 

Functions

kaa_error_t ext_log_storage_allocate_log_record_buffer (void *context, kaa_log_record_t *record)
 Allocates the data buffer to serialize a log entry into. More...
 
kaa_error_t ext_log_storage_deallocate_log_record_buffer (void *context, kaa_log_record_t *record)
 Deallocates the data buffer of a log record. More...
 
kaa_error_t ext_log_storage_add_log_record (void *context, kaa_log_record_t *record)
 Adds a log entry to the log storage. More...
 
kaa_error_t ext_log_storage_write_next_record (void *context, char *buffer, size_t buffer_len, uint16_t *bucket_id, size_t *record_len)
 Writes the next unmarked log entry into the supplied buffer and marks it with bucket_id the record size does not exceed the buffer_len. More...
 
kaa_error_t ext_log_storage_remove_by_bucket_id (void *context, uint16_t bucket_id)
 Removes from the storage all records marked with the provided bucket_id. More...
 
kaa_error_t ext_log_storage_unmark_by_bucket_id (void *context, uint16_t bucket_id)
 Unmarks all records marked with the provided bucket_id. More...
 
size_t ext_log_storage_get_total_size (const void *context)
 Returns total size occupied by logs in the log storage. More...
 
size_t ext_log_storage_get_records_count (const void *context)
 Returns total log records count. More...
 
kaa_error_t ext_log_storage_destroy (void *context)
 Destroys the log storage (which may decide to self-destroy). More...
 

Detailed Description

External log storage interface used by Kaa data collection subsystem to temporarily store the logs before sending them to Operations server.

Must be implemented in a concrete application for the data collection feature to function.

Function Documentation

kaa_error_t ext_log_storage_add_log_record ( void *  context,
kaa_log_record_t record 
)

Adds a log entry to the log storage.

In case of success assumes ownership of the record data buffer. (No need to call ext_log_storage_deallocate_log_record_buffer.)

Parameters
[in]contextLog storage context.
[in]recordLog record to add to log storage.
Returns
Error code.
kaa_error_t ext_log_storage_allocate_log_record_buffer ( void *  context,
kaa_log_record_t record 
)

Allocates the data buffer to serialize a log entry into.

Allocates the data buffer of size bytes in the record.

Parameters
[in]contextLog storage context.
[in,out]recordLog record to allocate buffer to.
Returns
Error code.
kaa_error_t ext_log_storage_deallocate_log_record_buffer ( void *  context,
kaa_log_record_t record 
)

Deallocates the data buffer of a log record.

Deallocates the data buffer in the record and sets size to 0.

Parameters
[in]contextLog storage context.
[in,out]recordLog record to deallocate buffer of.
Returns
Error code.
kaa_error_t ext_log_storage_destroy ( void *  context)

Destroys the log storage (which may decide to self-destroy).

Parameters
[in]contextLog storage context.
Returns
Error code
size_t ext_log_storage_get_records_count ( const void *  context)

Returns total log records count.

Parameters
[in]contextLog storage context.
Returns
Total amount of log records in the storage. Zero in case of errors.
size_t ext_log_storage_get_total_size ( const void *  context)

Returns total size occupied by logs in the log storage.

Parameters
[in]contextLog storage context.
Returns
Total log storage size in bytes, occupied by log records. Zero in case of errors.
kaa_error_t ext_log_storage_remove_by_bucket_id ( void *  context,
uint16_t  bucket_id 
)

Removes from the storage all records marked with the provided bucket_id.

Parameters
[in]contextLog storage context.
[in]bucket_idNon-zero bucket ID to search for records to be removed.
Returns
Error code
kaa_error_t ext_log_storage_unmark_by_bucket_id ( void *  context,
uint16_t  bucket_id 
)

Unmarks all records marked with the provided bucket_id.

Parameters
[in]contextLog storage context.
[in]bucket_idNon-zero bucket ID to search for records to be unmarked.
Returns
Error code
kaa_error_t ext_log_storage_write_next_record ( void *  context,
char *  buffer,
size_t  buffer_len,
uint16_t *  bucket_id,
size_t *  record_len 
)

Writes the next unmarked log entry into the supplied buffer and marks it with bucket_id the record size does not exceed the buffer_len.

Parameters
[in]contextLog storage context.
[in]bufferBuffer to write next unmarked record into.
[in]buffer_lenBuffer length in bytes.
[out]bucket_idOptional bucket ID of the next record.
[out]record_lenSize of the record data.
Returns
Error code
Return values
KAA_ERR_NONEa record of record_len was successfully written into the buffer.
KAA_ERR_NOT_FOUNDthere were no unmarked records in the storage. record_len is set to 0 in this case.
KAA_ERR_INSUFFICIENT_BUFFERthe buffer size was not sufficient to fit in the next unmarked entry. record_len is set to the size of the record that was not written.