Compartir a través de


Writing Your Own CeLog Flush Application (Windows CE 5.0)

Send Feedback

You can modify the operation of CeLogFlush and OSCapture by changing their code to do what you want. You can find the code for these applications under %_WINCEROOT%\public\common\sdk\samples\CeLog\flush. For instructions on rebuilding this code, see Rebuilding the CeLog Flush Applications.

You can also create your own flush application. If you wish to use your flush application with the default event-tracking library CeLog.dll, your flush application must interact CeLog.dll through a RAM buffer. The RAM buffer is the interface between the event tracking library that places data into the buffer, and the flushing application, which removes it. To communicate properly, both sides must interpret the data in the same way and follow certain rules about adding and removing data from the buffer. For more information, see CeLog Buffering Scheme.

CeLog.dll does not generate CELID_DATA_LOSS data loss events. Flush applications like CeLogFlush.exe are responsible for creating the data loss event and adding it to the event stream. This allows the flush application to ensure that the data loss events are not lost.

CeLogFlush.exe logs a CELID_DATA_LOSS event after every flush. If no data is lost, it writes a zero. If data is lost, CeLogFlush writes a value for the amount of lost data. When you run a log-viewing tool like Readlog, that tool can use the data loss counters to determine what periods of time involved data loss. By examining the data loss counters, you can identify what periods of time might be suspicious, and what periods of time you can trust. Typically, if data is lost, then the data is lost from the period of time immediately before the non-zero counter.

The following code sample shows how your flush application can record data loss events.

void WriteLossCounter(MAPHEADER* pHeader)
{
    static DWORD dwPrevCount = 0;
    DWORD dwCurrentCount;

    // Keep a local copy in case it changes asynchronously
    dwCurrentCount = pHeader->dwLostBytes;

    if (dwCurrentCount != dwPrevCount) {
        // The data loss count has increased since last time this code executed.

        // Convenient structure for logging the change in a CELID_DATA_LOSS event
        struct {
            CEL_HEADER header;
            CEL_DATA_LOSS loss;
        } MyDataLossEvent;
        MyDataLossEvent.header.ID = CELID_DATA_LOSS;
        MyDataLossEvent.header.Length = sizeof(MyDataLossEvent.loss);
        MyDataLossEvent.header.fTimeStamp = FALSE;
        MyDataLossEvent.loss.dwBytes = dwCurrentCount - dwPrevCount;

        // Now write the MyDataLossEvent structure to the log file - not shown here.

        // Remember the counter value for next time
        dwPrevCount = dwCurrentCount;
    }
}

See Also

CeLog Tool Customization | Avoiding CeLog Data Loss

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.