OnixS BME SENAF Handler C++ library  2.2.0
API documentation
Replaying Log Files

Using Logs to Replay Market Data

Under normal flow, Handler logs all important aspects of its execution onto file system. Log files include also original market data processed by the Handler. This information is usually saved for analysis of non-standard situations which may occur during use of the Handler. However, it also can be used to reproduce normal Handler's behavior for a certain period of time.

Once Handler was executed with logging enabled, it's possible to use log files for further replay. First of all, logs must be backed up (copied to another location) or Handler's configuration must be updated to use another directory for new logs. This is because current implementation of the Handler doesn't support replay from the same folder in which new logs will be stored.

Note
Handler will not replay log files produced by itself with logging mode set to OnixS::Senaf::MarketData::AdvancedLogOptions::LogNothing and OnixS::Senaf::MarketData::LogLevel::Fatal. This is because no required data is saved in those modes. To produce log files suitable for further replay Handler's logging must be configured with OnixS::Senaf::MarketData::AdvancedLogOptions::TraceToFile or OnixS::Senaf::MarketData::LogLevel::Debug logging mode.

Market data replay can be done with the help of OnixS::Senaf::MarketData::Handler::start method. It uses OnixS::Senaf::MarketData::HandlerSettings::logs member containing list of logs to be replayed.

It's possible manually define list of log files to be replayed. Manually manipulating list of log files allows replaying log files whose names differ from names used by the Handler.

HandlerSettings handlerSettings;
handlerSettings.logs.push_back("log.log");
handlerSettings.logs.push_back("log.log.1");
handlerSettings.logs.push_back("log.log.2");
Note
Files to be replayed must be in exact order as they were recorded by the Handler in bounds of single processing session.

From listener callbacks perspective, there's no difference whether Handler processes market data from the network or from log files.

Note
In case of live market data processing, Handler raises events reflecting processing results as soon as market data is received from the network and processed. However, SENAF spreads market data with different frequency, which depends on live market activity. Therefore, there're delays of different duration between triggered events. When log file is replayed, Handler does not do any pauses between data items and thus raises corresponding events as soon as data is retrieved from the log file.

When market data is being replayed, OnixS::Senaf::MarketData::MessageInfo::receiveTime member returns time of corresponding log file entry. Therefore, the value returned by given member represents original time when market data packet was obtained from the network.

Note
Currently, log replay must be run with the same set of Handler's settings which were originally used.

Sample application demonstrating Log Replay feature can be found in samples/LogReplay subfolder of Handler distributive package.