diff mbox series

[v6,2/4] log: introduce macro for maximum level

Message ID 20210406131137.1732110-3-thomas@monjalon.net (mailing list archive)
State Superseded
Delegated to: David Marchand
Headers show
Series log level enhancements | expand

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Thomas Monjalon April 6, 2021, 1:11 p.m. UTC
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>
---
 lib/librte_eal/common/eal_common_log.c     | 8 ++++----
 lib/librte_eal/common/eal_common_options.c | 2 +-
 lib/librte_eal/include/rte_log.h           | 1 +
 3 files changed, 6 insertions(+), 5 deletions(-)

Comments

David Marchand April 6, 2021, 2:32 p.m. UTC | #1
On Tue, Apr 6, 2021 at 3:11 PM Thomas Monjalon <thomas@monjalon.net> wrote:
>
> 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>
diff mbox series

Patch

diff --git a/lib/librte_eal/common/eal_common_log.c b/lib/librte_eal/common/eal_common_log.c
index 058fa10ffc..b9b982fdb5 100644
--- a/lib/librte_eal/common/eal_common_log.c
+++ b/lib/librte_eal/common/eal_common_log.c
@@ -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) {
diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c
index cd1a2856c9..38b72fb665 100644
--- a/lib/librte_eal/common/eal_common_options.c
+++ b/lib/librte_eal/common/eal_common_options.c
@@ -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;
 	}
diff --git a/lib/librte_eal/include/rte_log.h b/lib/librte_eal/include/rte_log.h
index 21a7d16340..424dfa3fd0 100644
--- a/lib/librte_eal/include/rte_log.h
+++ b/lib/librte_eal/include/rte_log.h
@@ -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.