Mstdlib-1.24.0
|
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) |
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.
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.
[in] | log | logger object |
[in] | buf_size | max size (in bytes) of memory buffer |
[in] | buf_time_s | max time (in seconds) to allow buffer to exist in memory before it's automatically deleted |
[in] | expire_cb | callback to call when a memory buffer is automatically deleted |
[in] | expire_thunk | any state used by the expire callback (not owned by log, you must delete it yourself) |
[out] | out_mod | handle for created module, or NULL if there was an error |
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.
[in] | log | logger object |
[in] | module | handle of module to operate on |
[out] | out_buf | buffer containing membuf data, or NULL if there was an error |