How to Use SimReport

Collect, store, and inspect simulation messages, warnings, and errors with CSimReports.

This guide shows you how to set up centralized simulation reporting with CSimReports, log messages of different severities, and read the report buffer back.

1. Understand CSimReports

The CSimReports class provides a centralized system for collecting, storing, and reporting simulation messages, warnings, errors, and informational logs. It supports both persistent in-memory storage and dynamic reporting with optional formatting.

2. Know the Internal Structure

MemberDescription
simEngReportsUnique pointer to shared memory for storing all report messages.
textRaw character buffer containing report text.
reportsSizeCurrent size of the report buffer.
errorListMap of unique errors to CError structures that store position, length, and occurrence count.

CSimReports::CError represents an individual tracked error or warning:

3. Set Up Reporting

  1. Call CSimReports::SetupReports() once to initialize the reporting system.
  2. Log messages as your simulation runs (see next section for the available methods).
  3. Read back the report buffer whenever you need to inspect it.

4. Log Messages

Use the appropriate call for the kind of message you need to record:

// Setup the reporting system
CSimReports::SetupReports();

// Simple informational message
CSimReports::ReportMsg(CSimReports::eInfo, "Simulation started");

// Message with additional details
CSimReports::ReportMsg(CSimReports::eWarning, "Potential issue detected", "Extra info", 5);

// Formatted report
CSimReports::Report(CSimReports::eError, "Error code %d at frame %d", errorCode, frameNum);

5. Read the Report Buffer

// Access raw report data
size_t size;
uint8_t* reportData = CSimReports::GetReportPtr(size);
if(reportData) {
    // process report buffer
}

6. Keep These Notes in Mind