Table of contents
- 1. Filter Mask
- 2.
- 3. Event Output
The turboExchange.DLL has two logging options, to keep track of what it's doing.
- Console output (default)
All activity is output to the standard Console. A filter can be set, so that some types of activity can be ignored.
- Event output
By subscribing to the logger, log data raises an event, which you can catch and deal with appropriately.
Filter Mask
The filter mask, allows only the required log messages to get written to the console or fire an event. Some types of event, such as a 'ping' or debug information is usually undesirable for normal operation.
This is the default setting.
clsLog.LogOutputMask = (uint)(LogItem.LogType.Error
| LogItem.LogType.RxProtoBuf
| LogItem.LogType.TxProtobuf
| LogItem.LogType.Verbose
| LogItem.LogType.SystemEvent);
Event Output
Internally, all logging is written to a protobuffer class's, called LogItem. As default these are converted to a string, and output to the console. To intercept those messages, add this code:
Subscribe to logger event:
turboExchange.clsLog.NewLogItem +=new turboExchange.clsLog.EventHandler_NewLogItem(clsLog_NewLogItem);
Handle event:
void clsLog_NewLogItem(turboExchange.Messages.LogItem logItem)
{
...
}
Unsubscribe to logger event (program close):
turboExchange.clsLog.NewLogItem -=new turboExchange.clsLog.EventHandler_NewLogItem(clsLog_NewLogItem);
Note: If your manipulating a WinForms control from any event the DLL provides, make sure you wrap your code with an .Invoke, to prevent cross threading issues.
e.g:
this.Invoke(new EventHandler(delegate
{
//.... your code
}));
