Mstdlib-1.24.0
Stream Module

Functions

M_log_error_t M_log_module_add_stream (M_log_t *log, M_stream_type_t type, size_t max_queue_bytes, M_log_module_t **out_mod)
 

Detailed Description

Functions to enable logging to streams (stdout, stderr).

Not available when building for Android platform.

Function Documentation

◆ M_log_module_add_stream()

M_log_error_t M_log_module_add_stream ( M_log_t log,
M_stream_type_t  type,
size_t  max_queue_bytes,
M_log_module_t **  out_mod 
)

Add a module to output to a standard stream (stdout, stderr).

If the library was compiled on a platform that doesn't allow console output (e.g., Android), this function will return M_LOG_MODULE_UNSUPPORTED when called, and no module will be added to the logger.

Warning
Normally, you should only add at most one stream output module to a given M_log_t object. This is because having multiple backends write to the same console stream may cause the output from each thread to become intermingled and unreadable. Plus, there's only one global thing you're writing too, it doesn't make any sense to output to it from a bunch of separate worker threads. Just use one backend per destination.
Parameters
[in]loglogger object
[in]typewhat stream to output to (stdout, stderr)
[in]max_queue_bytesmax size of queue used to buffer asynchronous writes to the stream
[in]out_modhandle for created module, or NULL if there was an error
Returns
error code