log: introduce macro for maximum level

RTE_DIM(...) and RTE_LOG_DEBUG were used to get the highest log level.
For better clarity a new constant RTE_LOG_MAX is introduced
and mapped to RTE_LOG_DEBUG.

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Reviewed-by: David Marchand <david.marchand@redhat.com>
This commit is contained in:
Thomas Monjalon 2021-04-08 18:47:11 +02:00 committed by David Marchand
parent 867bb637ae
commit 806d888a80
3 changed files with 6 additions and 5 deletions

View File

@ -140,7 +140,7 @@ rte_log_set_level(uint32_t type, uint32_t level)
{
if (type >= rte_logs.dynamic_types_len)
return -1;
if (level > RTE_LOG_DEBUG)
if (level > RTE_LOG_MAX)
return -1;
rte_logs.dynamic_types[type].loglevel = level;
@ -155,7 +155,7 @@ rte_log_set_level_regexp(const char *regex, uint32_t level)
regex_t r;
size_t i;
if (level > RTE_LOG_DEBUG)
if (level > RTE_LOG_MAX)
return -1;
if (regcomp(&r, regex, 0) != 0)
@ -219,7 +219,7 @@ rte_log_set_level_pattern(const char *pattern, uint32_t level)
{
size_t i;
if (level > RTE_LOG_DEBUG)
if (level > RTE_LOG_MAX)
return -1;
for (i = 0; i < rte_logs.dynamic_types_len; i++) {
@ -323,7 +323,7 @@ rte_log_register_type_and_pick_level(const char *name, uint32_t level_def)
return type;
TAILQ_FOREACH(opt_ll, &opt_loglevel_list, next) {
if (opt_ll->level > RTE_LOG_DEBUG)
if (opt_ll->level > RTE_LOG_MAX)
continue;
if (opt_ll->pattern) {

View File

@ -1249,7 +1249,7 @@ eal_parse_log_priority(const char *level)
return -1;
/* look for named values, skip 0 which is not a valid level */
for (i = 1; i < RTE_DIM(levels); i++) {
for (i = 1; i <= RTE_LOG_MAX; i++) {
if (strncmp(levels[i], level, len) == 0)
return i;
}

View File

@ -72,6 +72,7 @@ extern "C" {
#define RTE_LOG_NOTICE 6U /**< Normal but significant condition. */
#define RTE_LOG_INFO 7U /**< Informational. */
#define RTE_LOG_DEBUG 8U /**< Debug-level messages. */
#define RTE_LOG_MAX RTE_LOG_DEBUG /**< Most detailed log level. */
/**
* Change the stream that will be used by the logging system.