Tuesday, July 5, 2011

Octane SDK Debug Logging

The Octane SDK supports various levels of logging. The data available ranges from informational items to very verbose debug logging. In this post, I'll show you how to enable the most detailed logging and write the data to file.
// Declare a stream writer. 
// We'll use this to write the debug data to file.
static StreamWriter debugLogStream;

static void Main(string[] args)
{
// Open a new file to hold the debug information.
debugLogStream = new StreamWriter("debug.log", false);

// Enable debug logging.
Reader.LogLevel = LogLevel.Debug;
// Specify a method to handle logging events.
Reader.Logging += OnDebugLogging;

/////////////////////////////////////////////
// Do your RFID stuff here
/////////////////////////////////////////////

// Close the debug log file.
debugLogStream.Close();
}

// This method gets called by the Octane SDK
// when there is debug information available.
static void OnDebugLogging(object sender, LoggingEventArgs args)
{
// Write the debug message to file.
debugLogStream.WriteLine(args.Entry.Message);
debugLogStream.Flush();
}