Hash :
87042776
Author :
Date :
2025-08-21T19:30:37
logging: Encode verbosity values in an enum This enables to provide semantics and to ensure we use the values uniformly in the code base. While one could expect that verbosity `0` silences the logging, it is actually our default verbosity level for a long time. So this commit does not change that in order to avoid possible breakage. Silencing the logging is achieved by using a negative value for the verbosity level.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
// NOTE: This file has been generated automatically by “{{script}}”.
// Do not edit manually!
#pragma once
#include "config.h"
#include <stdint.h>
/*
* Macro sorcery: PREPEND_MESSAGE_ID enables the log functions to format messages
* with the message ID only if the ID is not 0 (XKB_LOG_MESSAGE_NO_ID).
* This avoid checking the ID value at run time.
*
* The trick resides in CHECK_ID:
* • CHECK_ID(0) expands to:
* ‣ SECOND(MATCH0, WITH_ID, unused)
* ‣ SECOND(unused,WITHOUT_ID, WITH_ID, unused)
* ‣ WITHOUT_ID
* • CHECK_ID(123) expands to:
* ‣ SECOND(MATCH123, WITH_ID, unused)
* ‣ WITH_ID
*/
#define EXPAND(...) __VA_ARGS__ /* needed for MSVC compatibility */
#define JOIN_EXPAND(a, b) a##b
#define JOIN(a, b) JOIN_EXPAND(a, b)
#define SECOND_EXPAND(a, b, ...) b
#define SECOND(...) EXPAND(SECOND_EXPAND(__VA_ARGS__))
#define MATCH0 unused,WITHOUT_ID
#define CHECK_ID(value) SECOND(JOIN(MATCH, value), WITH_ID, unused)
#define FORMAT_MESSAGE_WITHOUT_ID(id, fmt) fmt
#define FORMAT_MESSAGE_WITH_ID(id, fmt) "[XKB-%03d] " fmt, id
#define PREPEND_MESSAGE_ID(id, fmt) JOIN(FORMAT_MESSAGE_, CHECK_ID(id))(id, fmt)
/**
* Set of verbosity levels
*/
enum xkb_log_verbosity {
XKB_LOG_VERBOSITY_SILENT = -1,
XKB_LOG_VERBOSITY_MINIMAL = 0,
XKB_LOG_VERBOSITY_BRIEF = 1,
XKB_LOG_VERBOSITY_DETAILED = 5,
XKB_LOG_VERBOSITY_VERBOSE = 10,
XKB_LOG_VERBOSITY_COMPREHENSIVE = 11,
XKB_LOG_VERBOSITY_DEFAULT = XKB_LOG_VERBOSITY_MINIMAL,
};
/**
* Special case when no message identifier is defined.
*/
#define XKB_LOG_MESSAGE_NO_ID 0
/**
* @name Codes of the log messages
*/
enum xkb_message_code {
_XKB_LOG_MESSAGE_MIN_CODE = {{ entries[0].code }},
{% for entry in entries %}
/** {{ entry.description }} */
{{ entry.message_code_constant }} = {{ entry.code }},
{% endfor %}
_XKB_LOG_MESSAGE_MAX_CODE = {{ entries[-1].code }}
};
typedef uint32_t xkb_message_code_t;