Share via


Logging Events Using Pre-Defined Data Types (Windows CE 5.0)

Send Feedback

The CeLog event-tracking subsystem includes a set of pre-defined data types that you can use when logging your own events. You can instrument your code using these data types in calls to CeLogData. Or, if you only need to log a string value, you can use CeLogMsg.

After you have instrumented your code with calls to CeLogData or CeLogMsg, and run your code to capture data, you can view your data in Remote Kernel Tracker and Readlog. For more information, see Viewing Events from Pre-Defined Data Types.

CeLogData

When you call CeLogData, you provide a data type, size, and zone. The pre-defined data types compose arrays of one or more basic data types. For example, CELID_RAW_ULONG defines one or more ULONG values, and CELID_RAW_WCHAR defines a single character or a string. For a complete list of pre-defined data types, see CeLog Pre-Defined Data Types. The size of the data type array is indicated in the wLen parameter you provide to CeLogData.

The zone you provide determines whether CeLogData logs your data. You can prevent logging for certain kinds of data by disabling a zone, or authorize logging data by enabling a relevant zone. For a complete list of zones, see CeLog Zones.

The following example makes two CeLogData calls to log the values defined in the data types CELID_RAW_ULONG and CELID_RAW_WCHAR. The example logs every occurrence of these values by using the CELZONE_ALWAYSON, which cannot be disabled.

    DWORD DataArray[3] = { 1234, 5678, 9101 };
    TCHAR MyString[] = TEXT("This is my string.");

    CeLogData(TRUE, CELID_RAW_ULONG, DataArray, 3*sizeof(DWORD),
              0, CELZONE_ALWAYSON, 0, FALSE);

    CeLogData(TRUE, CELID_RAW_WCHAR, MyString,
              (_tcslen(MyString) + 1)*sizeof(TCHAR),
              0, CELZONE_ALWAYSON, 0, FALSE);

CeLogMsg

You can also use CeLogMsg to log string data. The following line shows an example of a CeLogMsg call.

    CeLogMsg(TEXT("This is my value: %u\r\n"), dwValue);

CeLogMsg performs string processing and then calls CeLogData with the CELID_RAW_WCHAR type. CeLogMsg always logs to the zone CELZONE_ALWAYSON, which cannot be turned off. If you need to use zones to filter your data, you must use CeLogData instead of CeLogMsg.

While CeLogMsg provides a convenient way to quickly record information from code, be aware that string representations of your data require much more log space than binary representations. This can lead to problems like CeLog data loss or decreased performance.

If you print many values into one string, or print them often, consider logging a binary version of your data as a custom data structure instead. For more information, see Capturing Events with Custom Data Structures.

Flagging multiple calls

If you log the same data in multiple places, consider using flags to identify different locations from which the data is logged. For more information, see Using Flags with Your Events.

Improving performance for ship builds

To minimize the size of your executable and improve performance in ship builds, remove CeLogData and CeLogMsg calls from the build with CeLog macros. For more information, see Using Macros to Improve Performance in Ship Builds.

See Also

Viewing Events from Pre-Defined Data Types | Capturing Events with Custom Data Structures

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.