mdbx: clarify loglevel descriptions.

This commit is contained in:
Леонид Юрьев (Leonid Yuriev) 2022-02-17 02:30:16 +03:00
parent a0728023cd
commit 77f236db2a
2 changed files with 46 additions and 34 deletions

50
mdbx.h
View File

@ -784,36 +784,51 @@ enum MDBX_constants {
* \note Most of debug feature enabled only when libmdbx builded with
* \ref MDBX_DEBUG build option. @{ */
/** Log level (requires build libmdbx with \ref MDBX_DEBUG option) */
/** Log level
* \note Levels detailed than (great than) \ref MDBX_LOG_NOTICE
* requires build libmdbx with \ref MDBX_DEBUG option. */
enum MDBX_log_level_t {
/** Critical conditions, i.e. assertion failures */
/** Critical conditions, i.e. assertion failures.
* \note libmdbx always produces such messages regardless
* of \ref MDBX_DEBUG build option. */
MDBX_LOG_FATAL = 0,
/** Enables logging for error conditions and \ref MDBX_LOG_FATAL */
/** Enables logging for error conditions
* and \ref MDBX_LOG_FATAL.
* \note libmdbx always produces such messages regardless
* of \ref MDBX_DEBUG build option. */
MDBX_LOG_ERROR = 1,
/** Enables logging for warning conditions and \ref MDBX_LOG_ERROR ...
\ref MDBX_LOG_FATAL */
/** Enables logging for warning conditions
* and \ref MDBX_LOG_ERROR ... \ref MDBX_LOG_FATAL.
* \note libmdbx always produces such messages regardless
* of \ref MDBX_DEBUG build option. */
MDBX_LOG_WARN = 2,
/** Enables logging for normal but significant condition and
\ref MDBX_LOG_WARN ... \ref MDBX_LOG_FATAL */
/** Enables logging for normal but significant condition
* and \ref MDBX_LOG_WARN ... \ref MDBX_LOG_FATAL.
* \note libmdbx always produces such messages regardless
* of \ref MDBX_DEBUG build option. */
MDBX_LOG_NOTICE = 3,
/** Enables logging for verbose informational and \ref MDBX_LOG_NOTICE ...
\ref MDBX_LOG_FATAL */
/** Enables logging for verbose informational
* and \ref MDBX_LOG_NOTICE ... \ref MDBX_LOG_FATAL.
* \note Requires build libmdbx with \ref MDBX_DEBUG option. */
MDBX_LOG_VERBOSE = 4,
/** Enables logging for debug-level messages and \ref MDBX_LOG_VERBOSE ...
\ref MDBX_LOG_FATAL */
/** Enables logging for debug-level messages
* and \ref MDBX_LOG_VERBOSE ... \ref MDBX_LOG_FATAL.
* \note Requires build libmdbx with \ref MDBX_DEBUG option. */
MDBX_LOG_DEBUG = 5,
/** Enables logging for trace debug-level messages and \ref MDBX_LOG_DEBUG ...
\ref MDBX_LOG_FATAL */
/** Enables logging for trace debug-level messages
* and \ref MDBX_LOG_DEBUG ... \ref MDBX_LOG_FATAL.
* \note Requires build libmdbx with \ref MDBX_DEBUG option. */
MDBX_LOG_TRACE = 6,
/** Enables extra debug-level messages (dump pgno lists)
and all other log-messages */
* and all other log-messages.
* \note Requires build libmdbx with \ref MDBX_DEBUG option. */
MDBX_LOG_EXTRA = 7,
#ifdef ENABLE_UBSAN
@ -836,15 +851,16 @@ enum MDBX_debug_flags_t {
MDBX_DBG_NONE = 0,
/** Enable assertion checks.
* Requires build with \ref MDBX_DEBUG > 0 */
* \note Always enabled for builds with `MDBX_FORCE_ASSERTIONS` option,
* otherwise requires build with \ref MDBX_DEBUG > 0 */
MDBX_DBG_ASSERT = 1,
/** Enable pages usage audit at commit transactions.
* Requires build with \ref MDBX_DEBUG > 0 */
* \note Requires build with \ref MDBX_DEBUG > 0 */
MDBX_DBG_AUDIT = 2,
/** Enable small random delays in critical points.
* Requires build with \ref MDBX_DEBUG > 0 */
* \note Requires build with \ref MDBX_DEBUG > 0 */
MDBX_DBG_JITTER = 4,
/** Include or not meta-pages in coredump files.

View File

@ -1222,25 +1222,21 @@ MDBX_INTERNAL_FUNC void mdbx_debug_log_va(int level, const char *function,
int line, const char *fmt,
va_list args);
#define mdbx_log_enabled(msg) unlikely(msg <= mdbx_loglevel)
#if MDBX_DEBUG
#define mdbx_assert_enabled() unlikely(mdbx_runtime_flags &MDBX_DBG_ASSERT)
#define mdbx_audit_enabled() unlikely(mdbx_runtime_flags &MDBX_DBG_AUDIT)
#define mdbx_log_enabled(msg) unlikely(msg <= mdbx_loglevel)
#define mdbx_audit_enabled() unlikely((mdbx_runtime_flags & MDBX_DBG_AUDIT))
#else /* MDBX_DEBUG */
#define mdbx_log_enabled(msg) (msg < MDBX_LOG_VERBOSE && msg <= mdbx_loglevel)
#define mdbx_audit_enabled() (0)
#endif /* MDBX_DEBUG */
#if !defined(NDEBUG) || MDBX_FORCE_ASSERTIONS
#if MDBX_FORCE_ASSERTIONS
#define mdbx_assert_enabled() (1)
#elif MDBX_DEBUG
#define mdbx_assert_enabled() likely((mdbx_runtime_flags & MDBX_DBG_ASSERT))
#else
#define mdbx_assert_enabled() (0)
#endif /* NDEBUG */
#endif /* MDBX_DEBUG */
#endif /* assertions */
#if !MDBX_DEBUG && defined(__ANDROID_API__)
#define mdbx_assert_fail(env, msg, func, line) \
@ -1252,33 +1248,33 @@ void mdbx_assert_fail(const MDBX_env *env, const char *msg, const char *func,
#define mdbx_debug_extra(fmt, ...) \
do { \
if (MDBX_DEBUG && mdbx_log_enabled(MDBX_LOG_EXTRA)) \
if (mdbx_log_enabled(MDBX_LOG_EXTRA)) \
mdbx_debug_log(MDBX_LOG_EXTRA, __func__, __LINE__, fmt, __VA_ARGS__); \
} while (0)
#define mdbx_debug_extra_print(fmt, ...) \
do { \
if (MDBX_DEBUG && mdbx_log_enabled(MDBX_LOG_EXTRA)) \
if (mdbx_log_enabled(MDBX_LOG_EXTRA)) \
mdbx_debug_log(MDBX_LOG_EXTRA, NULL, 0, fmt, __VA_ARGS__); \
} while (0)
#define mdbx_trace(fmt, ...) \
do { \
if (MDBX_DEBUG && mdbx_log_enabled(MDBX_LOG_TRACE)) \
if (mdbx_log_enabled(MDBX_LOG_TRACE)) \
mdbx_debug_log(MDBX_LOG_TRACE, __func__, __LINE__, fmt "\n", \
__VA_ARGS__); \
} while (0)
#define mdbx_debug(fmt, ...) \
do { \
if (MDBX_DEBUG && mdbx_log_enabled(MDBX_LOG_DEBUG)) \
if (mdbx_log_enabled(MDBX_LOG_DEBUG)) \
mdbx_debug_log(MDBX_LOG_DEBUG, __func__, __LINE__, fmt "\n", \
__VA_ARGS__); \
} while (0)
#define mdbx_verbose(fmt, ...) \
do { \
if (MDBX_DEBUG && mdbx_log_enabled(MDBX_LOG_VERBOSE)) \
if (mdbx_log_enabled(MDBX_LOG_VERBOSE)) \
mdbx_debug_log(MDBX_LOG_VERBOSE, __func__, __LINE__, fmt "\n", \
__VA_ARGS__); \
} while (0)