rpma_log_set_function3
Set the logging function
Usage
#include <librpma.h>
typedef void rpma_log_function(
enum rpma_log_level level,
const char *file_name,
const int line_no,
const char *function_name,
const char *message_format,
...);
int rpma_log_set_function(rpma_log_function *log_function);
Overview
rpma_log_set_function() allows choosing the function which will get all the generated logging messages. The log_function can be either RPMA_LOG_USE_DEFAULT_FUNCTION which will use the default logging function (built into the library) or a pointer to a user-defined function.
Parameters of a user-defined log function are as follow:
- •
-
level - the log level of the message
- •
-
file_name - name of the source file where the message coming from. It could be set to NULL and in such case neither line_no nor function_name are provided.
- •
-
line_no - the source file line where the message coming from
- •
-
function_name - the function name where the message coming from
- •
-
message_format - printf(3)
-likeformat string of the message
- •
-
"..." - additional arguments of the message format string
The default logging function
The initial value of the logging function is RPMA_LOG_USE_DEFAULT_FUNCTION. This function writes messages to syslog(3) (the primary destination) and to stderr(3) (the secondary destination).
Return value
rpma_log_set_function() function returns 0 on success or error code on failure.
Errors
- •
-
RPMA_E_AGAIN - a temporary error occurred, the retry may fix the problem
Note
The logging messages on the levels above the RPMA_LOG_THRESHOLD level won't trigger the logging function.
The user defined function must be thread-safe.
Releases
2 releases since Debian 12 (Bookworm); the text changed 1 time.