[v2,01/17] log: add a per line log helper with parameterized prefix
Checks
Commit Message
Providing a custom prefix when logging is common for components. Lift
ISO C99 compliant helper macros from mlx5_common.h and provide
RTE_LOG_LINE_PREFIX macro that can expand similar to RTE_LOG_LINE with
a custom prefix and argument list.
Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
lib/log/rte_log.h | 14 ++++++++++++++
1 file changed, 14 insertions(+)
Comments
23/02/2024 00:46, Tyler Retzlaff:
> Providing a custom prefix when logging is common for components. Lift
> ISO C99 compliant helper macros from mlx5_common.h and provide
> RTE_LOG_LINE_PREFIX macro that can expand similar to RTE_LOG_LINE with
> a custom prefix and argument list.
[...]
> > +#define _RTE_LOG_COMMA ,
I'm not sure about the underscore at the beginning.
Anyway it is exported in the API.
By the way it should have a Doxygen comment.
> +
> +#define RTE_LOG_LINE_PREFIX(l, t, prefix, args, ...) do { \
> + RTE_LOG_CHECK_NO_NEWLINE(RTE_FMT_HEAD(prefix __VA_ARGS__ ,)); \
> + RTE_LOG(l, t, RTE_FMT(prefix RTE_FMT_HEAD(__VA_ARGS__ ,) "\n", \
> + args _RTE_LOG_COMMA RTE_FMT_TAIL(__VA_ARGS__ ,))); \
> +} while (0)
> +
> +#define RTE_LOG_DP_LINE_PREFIX(l, t, prefix, args, ...) do { \
> + RTE_LOG_CHECK_NO_NEWLINE(RTE_FMT_HEAD(prefix __VA_ARGS__ ,)); \
> + RTE_LOG_DP(l, t, RTE_FMT(prefix RTE_FMT_HEAD(__VA_ARGS__ ,) "\n", \
> + args _RTE_LOG_COMMA RTE_FMT_TAIL(__VA_ARGS__ ,))); \
> +} while (0)
Please could you add a Doxygen comment for each RTE_LOG_LINE variations,
including previous ones?
Would be nice to have an idea of the output what DP is doing.
@@ -379,6 +379,20 @@ int rte_vlog(uint32_t level, uint32_t logtype, const char *format, va_list ap)
RTE_FMT_TAIL(__VA_ARGS__ ,))); \
} while (0)
+#define _RTE_LOG_COMMA ,
+
+#define RTE_LOG_LINE_PREFIX(l, t, prefix, args, ...) do { \
+ RTE_LOG_CHECK_NO_NEWLINE(RTE_FMT_HEAD(prefix __VA_ARGS__ ,)); \
+ RTE_LOG(l, t, RTE_FMT(prefix RTE_FMT_HEAD(__VA_ARGS__ ,) "\n", \
+ args _RTE_LOG_COMMA RTE_FMT_TAIL(__VA_ARGS__ ,))); \
+} while (0)
+
+#define RTE_LOG_DP_LINE_PREFIX(l, t, prefix, args, ...) do { \
+ RTE_LOG_CHECK_NO_NEWLINE(RTE_FMT_HEAD(prefix __VA_ARGS__ ,)); \
+ RTE_LOG_DP(l, t, RTE_FMT(prefix RTE_FMT_HEAD(__VA_ARGS__ ,) "\n", \
+ args _RTE_LOG_COMMA RTE_FMT_TAIL(__VA_ARGS__ ,))); \
+} while (0)
+
#define RTE_LOG_REGISTER_IMPL(type, name, level) \
int type; \
RTE_INIT(__##type) \