[dpdk-dev] [PATCH 01/11] avp: implement dynamic logging
Olivier MATZ
olivier.matz at 6wind.com
Fri Dec 22 14:45:41 CET 2017
On Thu, Dec 21, 2017 at 10:02:14AM -0800, Ferruh Yigit wrote:
> On 12/20/2017 10:58 AM, Stephen Hemminger wrote:
> >> [1] something like:
> >> #define INIT_LOG_VAR_NAME(pmd, type) logtype_ ## pmd ## _ ## type
> >> #define INIT_LOG_FUNC_NAME(pmd, type) log_ ## pmd ## _ ## type
> >>
> >> #define PMD_INIT_LOG(pmd, type, level) \
> >> int INIT_LOG_VAR_NAME(pmd, type); \
> >> RTE_INIT(INIT_LOG_FUNC_NAME(pmd, type)); \
> >> static void INIT_LOG_FUNC_NAME(pmd, type)(void) \
> >> { \
> >> INIT_LOG_VAR_NAME(pmd, type) = rte_log_register("pmd."
> >> RTE_STR(pmd) "." RTE_STR(type)); \
> >> if (INIT_LOG_VAR_NAME(pmd, type) > 0) \
> >> rte_log_set_level(INIT_LOG_VAR_NAME(pmd, type),
> >> RTE_LOG_##level); \
> >> }
> >
> > That macro is a little complex. Also, for better or worse, the current
> > logging is done on a per driver basis. If we want to do something fancier
> > it should be in common EAL core.
>
> Of course, my intention was putting it into rte_log.h so updates in each driver
> will be minimal. But this can be done better to cover library updates as well.
It's a good idea.
Below is another proposition (untested) that panics if
rte_log_register() fails, and that defines a static variable with a
predefined name.
#define RTE_LOG_TYPE_REGISTER(name, level) \
static int name##_log_type; \
__attribute__((constructor, used)) \
static void rte_log_register_##name(void) \
{ \
name##_log_type = rte_log_register(#name); \
RTE_VERIFY(name##_log_type >= 0); \
rte_log_set_level(name##_log_type, level); \
}
More information about the dev
mailing list