I am glad I could help. Unfortunately, the sample didn’t make it into the DDK. 
As for documenting the ‘DoTraceLevelMessage()’ function, I think it’s time to explain some of the mystery in WPP:
Believe it or not, there *is* no DoTraceLevelMessage() function. (!) The addition of the below line to your SOURCES file actually is just telling the WPP preprocessor to look for a function of the given name, and interpret the arguments as shown. The defining of WPP_LEVEL_FLAGS_ENABLED is used to override the preprocessor’s standard test to see if it should log the event. So, a single “function” like “DoTraceLevelMessage(1, PNP_DEBUG, “This Message”)” actually gets translated into code that looks something like this:
if ( WPP_LEVEL_ENABLED(PNP_DEBUG) && WPP_CONTROL(WPP_BIT_PNP_DEBUG).Level <= 1 )
// does the trace
Which can be further broken down if you want, but I don’t want to do that currently. If you want the dirty details, look into the generated TMF file. ETW is really just an extension of a very efficient logging mechanism (based on WMI) that has a lot of macro’s to make it easy for developers to use.
To provide another example, let’s say you think that function name is too long, and you prefer to have the first argument be the flag (as opposed to the level). Just change your sources file to have:
RUN_WPP=$(SOURCES) -func:ShortD(FLAGS,LEVEL,MSG,…)
Well, that’s some of the secrets of the black art of Event Tracing for Windows. Good luck, and enjoy!
.
-----Original Message-----
From: Robert Stankey [mailto:xxxxx@lsil.com]
Sent: Monday, February 10, 2003 11:07 AM
On Mon, 10 Feb 2003 09:51:22 -0800, “Henry Gabryjelski”
wrote:
Hi Henry,
This is exactly what I’m looking for! I couldn’t find the example in
the DDK or SDK (build 3757). I had forgotten about the
DoTraceLevelMessage function (you mentioned it during the Driver
Workshop last November). In fact, a search of the DDK/SDK for the
function documentation reveals nothing. Should it be documented?
Regards,
Bob
>
>
>I think there is a “WppSamples\LevelFlagsExample” example in either the most recent SDK or DDK (not sure which, sorry!). I will give the overview here:
>
>WPP has two options to control printing messages, bits and levels. The trace.h file has the following added:
>#define WPP_LEVEL_FLAGS_LOGGER(lvl,flags) WPP_LEVEL_LOGGER(flags)
>#define WPP_LEVEL_FLAGS_ENABLED(lvl, flags) (WPP_LEVEL_ENABLED(flags) && WPP_CONTROL(WPP_BIT_ ## flags).Level <= lvl)
>
>Then, add the following line to your SOURCES file:
>RUN_WPP=$(SOURCES) -func:DoTraceLevelMessage(LEVEL,FLAGS,MSG,…)
>
>This allows you to do the following:
>DoTraceLevelMessage(3,PNP_DEBUG, “Hello, %s %d”, “World”, i);
>
>The above trace will only occur if BOTH the PNP_DEBUG flag is set and the level is >= 3. I think this is more of what you are looking for. The other alternative is to have multiple GUIDs, but I suggest the above (it’s cleaner).
>
>Hth,
>.
>
>-----Original Message-----
>From: Robert Stankey [mailto:xxxxx@lsil.com]
>Sent: Sunday, February 09, 2003 8:24 PM
>
>Per Henry’s comments, I modified my sources file to include ‘…/’ and
>my TMH file get created. Now I have another question… 
>
>My driver uses debug levels which consist of some major function (ex.
>PNP_DEBUG) and a level of debug detail (ex. LEVEL_1, LEVEL_2,
>LEVEL_3). In my header file I have something like this:
>
>#define PNP_DEBUG 0x00010000
>#define LEVEL_1 0x00000001
>#define LEVEL_2 0x00000002
>#define LEVEL_3 0x00000004
>
>Given this a debug message could be formatted as such:
>
>mpp_DebugPrint(PNP_DEBUG+LEVEL_2, “DispatchPnp: PnP received for
>devObj 0x%x\n”, deviceObject);
>
>I decided to convert the #defines using the WPP_DEFINE_BIT() macro but
>I get an “undeclared identifier” message on the example line above.
>Can anyone think of a creative way to make my “old” method of defining
>debug levels work with WPP? Of course, I could avoid using the WPP
>stuff altogether and “roll my own” tracing but I’d rather not.
>
>I have more debug #defines than what I’ve shown here so I can’t use
>WPP_DEFINE_BIT() to define all possible debug level combinations (all
>combinations would be greater than 32).
>
>Thanks,
>Bob
>
>
>