[PATCH v4 11/14] log: add a per line log helper

Thomas Monjalon thomas at monjalon.net
Tue Dec 19 16:45:19 CET 2023


18/12/2023 15:38, David Marchand:
> +#ifdef RTE_TOOLCHAIN_GCC
> +#define RTE_LOG_CHECK_NO_NEWLINE(fmt) \
> +	static_assert(!__builtin_strchr(fmt, '\n'), \
> +		"This log format string contains a \\n")
> +#else
> +#define RTE_LOG_CHECK_NO_NEWLINE(...)
> +#endif

No support in clang?

> +#define RTE_LOG_LINE(l, t, ...) do { \
> +	RTE_LOG_CHECK_NO_NEWLINE(RTE_FMT_HEAD(__VA_ARGS__ ,)); \
> +	RTE_LOG(l, t, RTE_FMT(RTE_FMT_HEAD(__VA_ARGS__ ,) "\n", \
> +		RTE_FMT_TAIL(__VA_ARGS__ ,))); \
> +} while (0)
> +
> +#define RTE_LOG_DP_LINE(l, t, ...) do { \
> +	RTE_LOG_CHECK_NO_NEWLINE(RTE_FMT_HEAD(__VA_ARGS__ ,)); \
> +	RTE_LOG_DP(l, t, RTE_FMT(RTE_FMT_HEAD(__VA_ARGS__ ,) "\n", \
> +		RTE_FMT_TAIL(__VA_ARGS__ ,))); \
> +} while (0)

I don't think we need a space between __VA_ARGS__ and the comma.




More information about the dev mailing list