PMEM_LOG_SET_THRESHOLD(3)

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

πŸ’– PMEM_LOG_SET_THRESHOLD(3) πŸ’–

okay bestie, welcome to the PMDK Programmer's Manual ✨ β€” this one's all about pmem_log_set_threshold, aka the lil function that decides how loud your logs are allowed to be. let's get into it 🫢


🌸 NAME 🌸

pmem_log_set_threshold β€” set the logging threshold value πŸ’…


✨ SYNOPSIS ✨

#include <libpmem.h>

enum pmem_log_level {
    PMEM_LOG_LEVEL_HARK,
    PMEM_LOG_LEVEL_FATAL,
    PMEM_LOG_LEVEL_ERROR,
    PMEM_LOG_LEVEL_WARNING,
    PMEM_LOG_LEVEL_NOTICE,
    PMEM_LOG_LEVEL_INFO,
    PMEM_LOG_LEVEL_DEBUG
};

enum pmem_log_threshold {
    PMEM_LOG_THRESHOLD,
    PMEM_LOG_THRESHOLD_AUX
};

int pmem_log_set_threshold(enum pmem_log_threshold threshold,
    enum pmem_log_level value);

like. look at her. iconic signature, no notes πŸ’–


πŸ¦‹ DESCRIPTION πŸ¦‹

so pmem_log_set_threshold() sets the logging threshold value. that's the whole job. very demure, very mindful ✨

the thresholds you can pick from are:

  • PMEM_LOG_THRESHOLD β€” the main threshold, the one that filters out the undesired logging messages. any message less severe than whatever this threshold's value says gets straight up ignored, so it never even makes it to the logging function (pls go peek at pmem_log_set_function(3) for that part). the default value is PMEM_LOG_WARNING. periodt.
  • PMEM_LOG_THRESHOLD_AUX β€” the auxiliary threshold, meant to be used inside the logging function itself (check pmem_log_get_threshold(3)). a custom logging function may or may not care about this threshold, it's fully up to the developer's needs, no pressure 🫢. for how the default logging function behaves, see pmem_log_set_function(3). and the initial value of this threshold is PMEM_LOG_LEVEL_HARK.

and the threshold values you can pass? those are defined by enum pmem_log_level, and here they are, listed in descending order of severity (so scariest first, cutest last πŸŽ€):

  • PMEM_LOG_LEVEL_HARK β€” only basic library info. you use this to effectively suppress the logging, since it's only used for a few messages when the program starts and whenever a new logging function is set. see pmem_log_set_function(3) for the tea β˜•
  • PMEM_LOG_LEVEL_FATAL β€” an error that causes the program to stop working immediately. sorry. 😭
  • PMEM_LOG_LEVEL_ERROR β€” an error that causes the current operation to fail πŸ’€
  • PMEM_LOG_LEVEL_WARNING β€” an unexpected situation that does NOT cause the current operation to fail πŸ™ˆ
  • PMEM_LOG_LEVEL_NOTICE β€” non-massive info, mostly related to public API function completions ✨
  • PMEM_LOG_LEVEL_INFO β€” massive info, like every single write operation indication. she's chatty fr fr
  • PMEM_LOG_LEVEL_DEBUG β€” debug info, e.g. a write operation dump πŸ›

πŸ’œ RETURN VALUE πŸ’œ

pmem_log_set_threshold() returns 0 on success πŸŽ‰ or returns a non-zero value and sets errno on failure. and on failure, the threshold value stays exactly where it was β€” no sneaky half-changes, she's not doing that to you πŸ’…


🌈 ERRORS 🌈

pmem_log_set_threshold() can set these errno values when it fails:

  • EINVAL β€” threshold is not PMEM_LOG_THRESHOLD nor PMEM_LOG_THRESHOLD_AUX
  • EINVAL β€” value is not defined by the enum pmem_log_level type
  • EAGAIN β€” multiple threads attempted to change the threshold value at the same time (concurrently πŸ‘€). a retry may fix the problem. this error is not expected when the function is called from just one thread at a time, so like, if you're single-threaded, you're chilling 🧘

πŸ‘‘ SEE ALSO πŸ‘‘

pmem_log_get_threshold(3), pmem_log_set_function(3).


lowkey the whole vibe of this page is: pick your threshold, respect the severity order, and don't let two threads fight over it at once πŸ’€

and that's the page, bestie!! this was brought to you by PMDK, dated 2025-07-24 β€” tysm for reading, mwah πŸ’–πŸŽ€βœ¨πŸ¦‹πŸŒΈπŸ’…πŸ«Ά

πŸ“¦ where this page comes from