Share via


Trace Levels in Unmanaged Code (C, C++, COM)

Note  This content applies to the Windows Logo Kit (WLK). For the latest information using the new Windows Hardware Certification Kit (HCK), see Windows HCK User's Guide on the Windows Hardware Dev Center.

In unmanaged code, a trace level tells DTM Logger two things: the type of information to be logged and what additional data is required. The trace level is passed to the Trace function or method, which takes a variable number of additional parameters. The number and type the parameters depend on the trace level value.

Level-dependent parameter examples

In the following C++ code example, a Message trace accepts one additional string parameter.

CWTTLogger.Trace(
   WTT_LVL_MSG,
   hDevice,
   L"This is a unit test."
);

However, a Bug trace accepts two additional parameters, a string (the bug database), and an integer (the bug number), as the following code example shows.

CWTTLogger.Trace(
   WTT_LVL_BUG,
   hDevice,
   L"BugDB",
   890403
);

Trace level and Trace function parameters

The following table shows the predefined trace levels and the additional parameters that the Trace and UserDefinedTrace functions require for each trace level. For more information about Trace function parameters, see CWTTLogger::Trace (C++), WTTLogTrace (C), or IWTTLog::Trace (COM).

Level Purpose C/C++ parameters COM parameters

WTT_LVL_MSG

Message

LPWSTR - printf-style format string ... - printf-style variable args

BSTR - the message string

WTT_LVL_ERR See the note below

Error

DWORD - error code DWORD - error type LPWSTR - source file name ULONG - source file line LPWSTR - additional user-supplied message DWORD - error code DWORD - error type BSTR - source file name ULONG - source file line BSTR - additional user-supplied message

WTT_LVL_ASSERT

Assertion

LPWSTR - source file name ULONG - source file line LPWSTR - additional user-supplied message BSTR - source file name ULONG - source file line BSTR - additional user-supplied message

WTT_LVL_INVALID_PARAM

Invalid parameter

LPWSTR - source file name ULONG - source file line BSTR - source file name ULONG - source file line

WTT_LVL_BUG

Known bug

LPWSTR - bug management database name ULONG - bug ID DWORD - bug type Where available bug types are: WTT_BUG_TYPE_BLOCKING - Bug blocking the test pass WTT_BUG_TYPE_NONBLOCKING - Bug non-blocking the test pass Any other value is treated as an unknown bug type. BSTR - bug management database name ULONG - bug ID DWORD - bug type Where available bug types are: WTT_BUG_TYPE_BLOCKING - Bug blocking the test pass WTT_BUG_TYPE_NONBLOCKING - Bug non-blocking the test pass Any other value is treated as an unknown bug type.

WTT_LVL_BREAK

Debug break

DWORD - error code DWORD - error type LPWSTR - source file name ULONG - source file line LPWSTR - additional user-supplied message DWORD - error code DWORD - error type BSTR - source file name ULONG - source file line BSTR - additional user-supplied message

WTT_LVL_WARN

Warning message

LPWSTR - source file name ULONG - source file line LPWSTR - additional user-supplied message BSTR - source file name ULONG - source file line BSTR - additional user-supplied message

WTT_LVL_FUNCTION

Function entry or exit points

LPWSTR - function name LPWSTR - source file name BSTR - function name BSTR - source file name

WTT_LVL_START_TEST

Start of a test case

Use StartTest or StartTestEx wrapper function instead

Use StartTest or StartTestEx wrapper function instead

WTT_LVL_END_TEST

End of a test case

Use EndTest or EndTestEx wrapper function instead

Use EndTest or EndTestEx wrapper function instead

WTT_LVL_TCMINFO

Tactics fields

int - Test case ID, usually set to -1 LPWSTR - Node path LPWSTR - Test case title - set later LPWSTR - Hash key LPWSTR - Created by LPWSTR - Modified by LPWSTR - Assigned to LPWSTR - Test type LPWSTR - Result type LPWSTR - Milestone ULONG - Priority ULONG - Test time LPWSTR - Comments LPWSTR - Method LPWSTR - Frequency LPWSTR - Description LPWSTR - Scripts LPWSTR - Log file path LPWSTR - Suite LPWSTR - Area LPWSTR - Component LPWSTR - Sub component LPWSTR - Dev LPWSTR - Test lead LPWSTR - Log table BOOL - Create only BOOL - Log only BOOL - Recursive int - Test case ID, usually set to -1 BSTR - Node path BSTR - Test case title - set later BSTR - Hash key BSTR - Created by BSTR - Modified by BSTR - Assigned to BSTR - Test type BSTR - Result type BSTR - Milestone ULONG - Priority ULONG - Test time BSTR - Comments BSTR - Method BSTR - Frequency BSTR - Description BSTR - Scripts BSTR - Log file path BSTR - Suite BSTR - Area BSTR - Component BSTR - Sub component BSTR - Dev BSTR - Test lead BSTR - Log table BOOL - Create only BOOL - Log only BOOL - Recursive

WTT_LVL_MACHINEINFO

Machine-related test case fields for Tactics

LPWSTR - OS LPWSTR - Service Pack LPWSTR - Platform (processor architecture) LPWSTR - Version (upgrade path) LPWSTR - VBL (build lab) LPWSTR - build number LPWSTR - build date LPWSTR - language LPWSTR - config BSTR - OS BSTR - Service Pack BSTR - Platform (processor architecture) BSTR - Version (upgrade path) BSTR - VBL (build lab) BSTR - build number BSTR - build date BSTR - language BSTR - config
WTT_LVL_ROLLUP See the note below

Test suite roll-up information

ULONG - number of passed test cases ULONG - number of warned test cases ULONG - number of failed test cases ULONG - number of blocked test cases ULONG - number of skipped test cases ULONG - number of passed test cases ULONG - number of warned test cases ULONG - number of failed test cases ULONG - number of blocked test cases ULONG - number of skipped test cases

 

Note  If the message string argument of the WTT_LVL_ERR trace level contains a string variable (%s), an error is thrown. To use a string variable, make it the first string of the argument list and make your message the second string of the argument list.

Note  In order for a PFRollup node to be added to the log file, you must call the Trace method with the WTT_LVL_ROLLUP trace level before closing the log device. In the managed interface, such a call is automatically provided for the user; but in unmanaged interfaces it is not provided. That is why the user must explicitly make this call.

 

 

Build date: 9/14/2012