Custom argument displayed as part of WPP tracing prefix

25 Views Asked by At

I already have WPP tracing enabled with a couple of functions that have a hardcoded prefix like so:

USEPREFIX(CUSTOM_LOG, "[Custom][%!FUNC!]");

What I am trying to achieve now is to create another function that takes a custom argument which will be used in the prefix:

Function:

FUNC PARAM_LOG{ LEVEL = TRACE_LEVEL_INFORMATION, FLAG = TRACE_ALL }(PARAM, MSG, ...);

Prefix:

USEPREFIX(PARAM_LOG, "[%!PARAM!][%!FUNC!]");

According to this OSR Community Question, that's possible but it requires a workaround which "hijacks" one of the predefined format strings. I tried implementing this with the COMPNAME format string by adding:

#define WPP_LEVEL_FLAG_COMPNAME_LOGGER(lvl, flags, compname) \
        WPP_LEVEL_LOGGER(flags)

#define WPP_LEVEL_FLAG_COMPNAME_ENABLED(lvl, flags, compname) \
        (WPP_LEVEL_ENABLED(flags) && WPP_CONTROL(WPP_BIT_ ## flags).Level >= lvl)

followed by

USEPREFIX(PARAM_LOG, "[%!COMPNAME!][%!FUNC!]");
FUNC PARAM_LOG{ LEVEL = TRACE_LEVEL_INFORMATION, FLAG = TRACE_ALL }(COMPANE, MSG, ...);

This doesn't cause any error but when I call the function:

char* module = "Module";
PARAM_LOG(module, "Message");

I get an empty module inside the .tmf file:

"[][%!FUNC!]:%10!s!" // LEVEL=TRACE_LEVEL_INFORMATION FLAG=TRACE_ALL COMPNAME=module FUNC=Log

I am relatively new to WPP tracing so I am not entirely sure what's causing that issue...

0

There are 0 best solutions below