rpma_log_set_function(3)
π rpma_log_set_function β bestie edition π
okay so this is a page from the RPMA Programmer's Manual, and today's main character is rpma_log_set_function(3). sit down, grab a boba, we're talking about where your logs go π«Ά
β¨ NAME β¨
rpma_log_set_function β set the logging function π
πΈ SYNOPSIS πΈ
#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);
like, that's the whole vibe. one function, one pointer, endless possibilities β¨
π¦ DESCRIPTION π¦
so rpma_log_set_function() is literally your chance to pick which function gets handed every single logging message the library generates. no cap. all of them. it's giving "you are the chosen one" energy π
and log_function can be one of two things:
RPMA_LOG_USE_DEFAULT_FUNCTIONβ which just uses the default logging function (built into the library, she's pre-installed bestie π)- or a pointer to a user-defined function that you wrote yourself. main character move fr fr
so what do the parameters of a user-defined log function even look like? let me put you on:
levelβ the log level of the message πfile_nameβ name of the source file where the message coming from. lowkey important: it could be set toNULL, and in that case neitherline_nonorfunction_nameare provided. so like, be ready for that πline_noβ the source file line where the message coming from πfunction_nameβ the function name where the message coming from π―message_formatβ aprintf(3)-like format 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. and what does that one do, you ask? she writes messages to syslog(3) (the primary destination) and to stderr(3) (the secondary destination). two destinations, one icon π
β RETURN VALUE β
rpma_log_set_function() returns 0 on success or an error code on failure. simple as that bestie β¨
π ERRORS π
RPMA_E_AGAINβ a temporary error occurred, the retry may fix the problem. so like, don't panic, just run it back π
π NOTE π
the logging messages on the levels above the RPMA_LOG_THRESHOLD level won't trigger the logging function. so if you're wondering why your logs are ghosting youβ¦ that's why π
also, the user defined function must be thread-safe. this is not a drill, this is not optional, this is the rule π’
π SEE ALSO π
rpma_log_get_threshold(3), rpma_log_set_threshold(3), librpma(7) and https://pmem.io/rpma/ β go read them, they're the friend group π«Ά
and that's the tea, bestie π this little gem comes to you from RPMA and it's dated 01 April 2024. now go forth and set your logging function like the icon you are π β¨π
π¦ where this page comes from
- ubuntu noble: librpma-dev 1.3.0-2build2 Β· BSD-3
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms