PMEM_LOG_SET_THRESHOLD(3)
π 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 atpmem_log_set_function(3)for that part). the default value isPMEM_LOG_WARNING. periodt.PMEM_LOG_THRESHOLD_AUXβ the auxiliary threshold, meant to be used inside the logging function itself (checkpmem_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, seepmem_log_set_function(3). and the initial value of this threshold isPMEM_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. seepmem_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 frPMEM_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 notPMEM_LOG_THRESHOLDnorPMEM_LOG_THRESHOLD_AUXEINVALβ value is not defined by theenum pmem_log_leveltypeEAGAINβ 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
- fedora 43: libpmem-devel 2.1.0-4.fc43 Β· BSD-3-Clause
- π the page's license: BSD-3-Clause
- Copyright 2024, Intel Corporation
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms