PMEMOBJ_LOG_SET_THRESHOLD(3)

πŸ“¦
version 2.1.0 Β· 2 versions
, in fedora 43

πŸ’– PMEMOBJ_LOG_SET_THRESHOLD πŸ’–

okay bestie, welcome to the PMDK Programmer's Manual ✨ you're literally about to learn how to set the logging threshold value, and honestly? it's giving main character energy. no cap, this one's short and sweet. let's go 🫢


🌸 NAME 🌸

pmemobj_log_set_threshold β€” set the logging threshold value


✨ SYNOPSIS ✨

like, here's the whole vibe, verbatim, don't touch it:

#include <libpmemobj.h>

enum pmemobj_log_level {
    PMEMOBJ_LOG_LEVEL_HARK,
    PMEMOBJ_LOG_LEVEL_FATAL,
    PMEMOBJ_LOG_LEVEL_ERROR,
    PMEMOBJ_LOG_LEVEL_WARNING,
    PMEMOBJ_LOG_LEVEL_NOTICE,
    PMEMOBJ_LOG_LEVEL_INFO,
    PMEMOBJ_LOG_LEVEL_DEBUG
};

enum pmemobj_log_threshold {
    PMEMOBJ_LOG_THRESHOLD,
    PMEMOBJ_LOG_THRESHOLD_AUX
};

int pmemobj_log_set_threshold(enum pmemobj_log_threshold threshold,
    enum pmemobj_log_level value);

πŸ¦‹ DESCRIPTION πŸ¦‹

so pmemobj_log_set_threshold() sets the logging threshold value. that's it. that's the whole job. πŸ’…

the thresholds you can pick from are:

  • PMEMOBJ_LOG_THRESHOLD β€” this is the main threshold, the one that filters out the logging messages you simply do not want. messages that are less severe than whatever this threshold's value says get ignored, so they never even make it to the logging function (go peek at pmemobj_log_set_function(3) for that whole situation). its default value is PMEMOBJ_LOG_WARNING.
  • PMEMOBJ_LOG_THRESHOLD_AUX β€” the auxiliary threshold, made for use inside the logging function (see pmemobj_log_get_threshold(3) if you're nosy πŸ‘€). a custom logging function may or may not care about this threshold, it's fully up to whatever the developer needs. and if you wanna know how the default logging function behaves, that's pmemobj_log_set_function(3) again. its initial value is PMEMOBJ_LOG_LEVEL_HARK.

and the actual threshold values? those come from the enum pmemobj_log_level type. here they are, listed from most severe to least severe, descending order, periodt:

  • PMEMOBJ_LOG_LEVEL_HARK β€” only basic library info. you use this to effectively suppress the logging, because it's only used for a few messages when the program starts up and whenever a new logging function gets set. see pmemobj_log_set_function(3).
  • PMEMOBJ_LOG_LEVEL_FATAL β€” an error that causes the program to stop working immediately. sorry. 😭
  • PMEMOBJ_LOG_LEVEL_ERROR β€” an error that causes the current operation or transaction to fail.
  • PMEMOBJ_LOG_LEVEL_WARNING β€” an unexpected situation that does NOT cause the current operation to fail. (yes the NOT is loud, it matters.)
  • PMEMOBJ_LOG_LEVEL_NOTICE β€” non-massive info, mostly about public API function completions.
  • PMEMOBJ_LOG_LEVEL_INFO β€” massive info, like, every single write operation indication. it's a lot. πŸ™ˆ
  • PMEMOBJ_LOG_LEVEL_DEBUG β€” debug info, e.g. a write operation dump.

πŸŽ€ RETURN VALUE πŸŽ€

pmemobj_log_set_threshold() returns 0 on success πŸ₯³ or it returns a non-zero value and sets errno on failure. and bestie, on failure, the threshold value stays exactly the way it was β€” nothing changes, it just says no. πŸ’€


πŸ”₯ ERRORS πŸ”₯

pmemobj_log_set_threshold() can set the following errno values when it fails:

  • EINVAL β€” threshold is not PMEMOBJ_LOG_THRESHOLD nor PMEMOBJ_LOG_THRESHOLD_AUX
  • EINVAL β€” value is not defined by the enum pmemobj_log_level type
  • EAGAIN β€” multiple threads tried to change the threshold value concurrently. a retry may fix the problem. this error is not expected when the function is called from just one thread at a time.
ngl if you're hitting EAGAIN, maybe check who else is in the group chat changing thresholds at the same time πŸ‘€ one thread at a time and you're golden.

🌈 SEE ALSO 🌈

pmemobj_log_get_threshold(3), pmemobj_log_set_function(3).


that's the whole page, bestie, you ate it πŸ’…βœ¨

PMDK β€” 2025-07-24 πŸ¦‹ mwah, go forth and log responsibly πŸ«ΆπŸŽ€

πŸ“¦ where this page comes from