DTM Logger Example Using C#
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.
The following code example shows how to use the DTM Logger in a C# application.
using System;
using System.IO;
using System.Runtime.Serialization;
using System.Xml.Serialization;
using Microsoft.Wtt.Log;
...
void DoSampleTest()
{
string deviceString = "$logfile:file=WTTLOGTest.xml,Writemode=overwrite";
m_Logger = new WttLogger(deviceString);
// Start a test case
m_Logger.StartTest("Test 1 - Testing Tracing functions");
m_Logger.Trace(new LevelError(0x3,ErrorType.Win32,"break"));
// Trace machine info
m_Logger.TraceMachineInfo();
// Trace a message by using a message string
m_Logger.Trace(new LevelMessage("Testing Tracing Messages"));
// Trace a message by using a user object only
Test1 userObject = new Test1();
m_Logger.Trace(new LevelMessage(userObject));
// Trace a message by using a user object and a message string
m_Logger.Trace(new LevelMessage("Testing Tracing Messages with user Objects",userObject));
// Trace a normal error
m_Logger.Trace(new LevelError(0x3,ErrorType.Win32,
"Testing Tracing Errors"));
try
{
// Generate IOException
File.Open("c:\toot.txt",FileMode.Open,FileAccess.Read,FileShare.Read);
}
catch(Exception exp)
{
// Trace an exception error
m_Logger.Trace(new LevelError(exp));
}
// End test case
m_Logger.EndTest("Test 1 - Testing Tracing functions",0,null);
}
See Also
Build date: 9/14/2012