Extended Time Logging

By configuring the log parameters appropriately, logging can be executed continuously for an indefinite period. The log data is stored in several files, and older files are deleted as more log data is collected to prevent excessive use of file storage space.

This type of logging is useful when capturing the log data during an event or error that rarely occurs. Typically, other status monitoring functions are used to detect the event or error and stop the log operation.

To execute logging over an extended time, set the following parameters:

  • maxLogFileCount - The max log file count should be set to 2 or greater. The log operation will overwrite the oldest file each time the maxLogFileSize is reached, and if maxLogFileCount is 1, the entire log data will be discarded at this time. To discard a smaller fraction of the total collected log data each time maxLogFileSize is written, set this parameter to a higher value.

  • maxLogFileSize - The max log file size should be set to a value greater than 0. If this value is set to 0, there is no maximum log file size, and the file storage space will be eventually expended as log data is collected. The total file storage space used by the log operation is equal to maxLogFileSize multiplied by maxLogFileCount.

  • stopLoggingOnBufferOverflow - This should optionally be set to 0 to prevent the log operation from stopping when a buffer overflow randomly occurs during an extended period of logging. However, if this option is set to 0, the obtained log data should be carefully analyzed to verify that no cyclic data was lost due to buffer overflow.

Extended Time Logging Example

The following code executes an extended log operation for one axis.

CoreMotionLogInput in;
LogChannelOptions opt;
LogFilePathW path;
unsigned int chnl = 0;

//Set the CoreMotion module to log the position command data of axis 0
in.axisSelection.axisCount = 1;
in.axisSelection.axis[0] = 0;
in.axisOptions.commandPos = 1;
wmxlib_Log->SetLog(chnl, &in);

//Set the log options
opt.samplingTimeMilliseconds = 0;
opt.isRotateFile = 1;
opt.maxLogFileCount = 4;
opt.maxLogFileSize = 1000000; //1MB
opt.stopLoggingOnBufferOverflow = 0;
wmxlib_Log->SetLogOption(chnl, &opt);

//Set the log output file path
swprintf(path.dirPath, L"C:");
swprintf(path.fileName, L"wmxlog.txt");
wmxlib_Log->SetLogFilePath(chnl, &path);

//Start log operation
wmxlib_Log->StartLog(chnl);

...

//When the event or error occurs, stop logging data
wmxlib_Log->StopLog(chnl);