Re: [dpdk-dev] [PATCH 01/13] eal/log: introduce log register macro
From: Sachin Saxena (OSS) <hidden>
Date: 2020-06-21 09:39:10
On 17-Jun-20 12:00 PM, jerinj@marvell.com wrote:
quoted hunk ↗ jump to hunk
From: Jerin Jacob <redacted> 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 <redacted> --- lib/librte_eal/include/rte_log.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)diff --git a/lib/librte_eal/include/rte_log.h b/lib/librte_eal/include/rte_log.h index 1789ede56..4dc357074 100644 --- a/lib/librte_eal/include/rte_log.h +++ b/lib/librte_eal/include/rte_log.h@@ -376,6 +376,31 @@ 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(RTE_STR(name)); \ + if (type >= 0) \ + rte_log_set_level(type, RTE_LOG_##level); \ +} + #ifdef __cplusplus } #endif
Do we like to add some way of notifying the driver (may be simple print) regarding failure case of "rte_log_*" API?