Mstdlib-1.24.0
Memory Buffer Module

Functions

M_log_error_t M_log_module_add_membuf (M_log_t *log, size_t buf_size, M_uint64 buf_time_s, M_log_expire_cb expire_cb, void *expire_thunk, M_log_module_t **out_mod)
 
M_log_error_t M_log_module_take_membuf (M_log_t *log, M_log_module_t *module, M_buf_t **out_buf)
 

Detailed Description

Functions to enable logging sensitive data to a temporary memory buffer.

Membuf modules only accept messages until they are full, then they stop accepting messages and hang out in memory until they're either explicitly retrieved by the caller with M_log_module_take_membuf(), or they reach their expiration time and are automatically destroyed.

Function Documentation

◆ M_log_module_add_membuf()

M_log_error_t M_log_module_add_membuf ( M_log_t log,
size_t  buf_size,
M_uint64  buf_time_s,
M_log_expire_cb  expire_cb,
void *  expire_thunk,
M_log_module_t **  out_mod 
)

Add a module to output to a buffer in memory.

This is intended for temporary, in-memory storage of sensitive data that can't be stored long-term.

Messages are accepted from the time the buffer is added, until the buffer is full. After that, no new messages are stored, and the contents are preserved until either the module is removed, or the expiration time is reached.

Parameters
[in]loglogger object
[in]buf_sizemax size (in bytes) of memory buffer
[in]buf_time_smax time (in seconds) to allow buffer to exist in memory before it's automatically deleted
[in]expire_cbcallback to call when a memory buffer is automatically deleted
[in]expire_thunkany state used by the expire callback (not owned by log, you must delete it yourself)
[out]out_modhandle for created module, or NULL if there was an error
Returns
error code

◆ M_log_module_take_membuf()

M_log_error_t M_log_module_take_membuf ( M_log_t log,
M_log_module_t module,
M_buf_t **  out_buf 
)

Remove a membuf module from the log and return the internal memory store.

This method should be used if you need to preserve the data stored in the buffer. If you just want to remove the module and you don't care about the memory buffer contents, you should call the normal M_log_module_remove() function instead.

See also
M_log_module_remove
Parameters
[in]loglogger object
[in]modulehandle of module to operate on
[out]out_bufbuffer containing membuf data, or NULL if there was an error
Returns
error code