[v4,01/13] eal/log: introduce log register macro
diff mbox series

Message ID 20200701104428.4149689-2-jerinj@marvell.com
State Superseded, archived
Delegated to: Thomas Monjalon
Headers show
Series
  • rte_log registration usage improvement
Related show

Checks

Context Check Description
ci/iol-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/Intel-compilation fail apply issues
ci/iol-nxp-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/checkpatch success coding style OK

Commit Message

Jerin Jacob Kollanukkaran July 1, 2020, 10:44 a.m. UTC
From: Jerin Jacob <jerinj@marvell.com>

Introducing the RTE_LOG_REGISTER macro to avoid the code duplication
in the log registration process.

It is a wrapper macro for declaring the logtype, register the log and sets
it's level in the constructor context.

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
Acked-by: Adam Dybkowski <adamx.dybkowski@intel.com>
---
 lib/librte_eal/include/rte_log.h | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

Patch
diff mbox series

diff --git a/lib/librte_eal/include/rte_log.h b/lib/librte_eal/include/rte_log.h
index 1789ede56..eaf66e4f6 100644
--- a/lib/librte_eal/include/rte_log.h
+++ b/lib/librte_eal/include/rte_log.h
@@ -376,6 +376,30 @@  int rte_vlog(uint32_t level, uint32_t logtype, const char *format, va_list ap)
 		 RTE_LOGTYPE_ ## t, # t ": " __VA_ARGS__) :	\
 	 0)
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice
+ *
+ * Register a dynamic log type in constructor context with its name and level.
+ *
+ * It is a wrapper macro for declaring the logtype, register the log and
+ * sets it's level in the constructor context.
+ *
+ * @param type
+ *   The log type identifier
+ * @param name
+ *    Name for the log type to be registered
+ * @param level
+ *   Log level. A value between EMERG (1) and DEBUG (8).
+ */
+#define RTE_LOG_REGISTER(type, name, level)				\
+int type;								\
+RTE_INIT(__##type)							\
+{									\
+	type = rte_log_register_type_and_pick_level(RTE_STR(name),	\
+						    RTE_LOG_##level);	\
+}
+
 #ifdef __cplusplus
 }
 #endif