|
LogViewer
A modern log viewer with AI-assisted analysis (Qt 6)
|
Parses merged test-run logs produced by the safeAPI RBC 2oo2 test environment (robot steps + container + simulator logs in one file). More...
#include <SapiLogParser.hpp>


Public Member Functions | |
| SapiLogParser ()=default | |
| ~SapiLogParser () override=default | |
| void | ParseData (const std::filesystem::path &filepath) override |
| Parses data from a file path. | |
| void | ParseData (std::istream &input) override |
| Parses data from an input stream. | |
| uint32_t | GetCurrentProgress () const override |
| Gets the current parsing progress. | |
| uint32_t | GetTotalProgress () const override |
| Gets the total expected progress value. | |
| std::vector< std::pair< std::string, std::string > > | GetFileMetadata () const override |
| void | RegisterObserver (IDataParserObserver *observer) |
| Registers an observer to receive parsing notifications. | |
| void | UnregisterObserver (IDataParserObserver *observer) |
| void | NotifyNewEvent (db::LogEvent &&event) |
| void | NotifyProgressUpdated () |
| void | NotifyNewEventBatch (std::vector< std::pair< int, db::LogEvent::EventItems > > &&eventBatch) |
Static Public Member Functions | |
| static bool | LooksLikeSapiLog (const std::filesystem::path &filepath) |
| static bool | ParseLine (std::string_view line, db::LogEvent::EventItems &out) |
| static void | ParseHeaderLine (std::string_view line, std::vector< std::pair< std::string, std::string > > &metadata) |
| static std::string_view | ExtractUnit (std::string_view info) |
| static void | ExtractPayloadFields (std::string_view payload, db::LogEvent::EventItems &out) |
Private Member Functions | |
| void | ParseStream (std::istream &input) |
Private Attributes | |
| uint32_t | m_currentProgress {0} |
| uint32_t | m_totalProgress {0} |
| std::vector< std::pair< std::string, std::string > > | m_metadata |
| std::vector< IDataParserObserver * > | observers |
Parses merged test-run logs produced by the safeAPI RBC 2oo2 test environment (robot steps + container + simulator logs in one file).
File layout: a #-prefixed header block, then one event per line, each field wrapped in square brackets:
Brackets may nest inside info and payload (e.g. [[ 419310003] [GW-IL EAST] starting]), so fields are split by bracket depth, not by a fixed regex. payload is everything after the 7th field; it may hold several bracket groups ([train_id=1] [P0] [cycle=1 ...]) — those are kept verbatim.
Parsed LogEvent fields: timestamp — ISO-8601 UTC string, unchanged (e.g. "2026-09-19T06:46:46.456779Z") category — "GENERAL" or "IO" source — emitting component (e.g. "a-west", "robot", "il-multi") destination — target component(s) or "internal" level — INFO / DEBUG / ERROR / FAIL event_type — LOG, STEP, ENVELOPE, CMD_RESP, ... info — short description payload — trailing data (omitted when empty) unit — 2oo2 channel from an info prefix like [a-west | GP] … (optional) p.<key> — structured payload content, see ExtractPayloadFields() (optional)
The header's # Key : Value lines are not events; they are available through GetFileMetadata() after parsing.
Lines that do not match the layout are skipped. If no line matches at all, ParseData() throws error::Error(ParseError) so a wrong file-type choice is reported instead of silently producing an empty view.
|
default |
|
overridedefault |
|
static |
Appends the structured content of payload to out as p.<key> fields. The raw payload is never modified. Recognised shapes:
p.<key>, members of a nested object p.<key>.<member>; strings are unquoted, anything deeper is kept as compact JSON text;key=value tokens (values may be quoted or hold balanced [...]/{...}); bracket groups of such tokens are unwrapped and single-word label groups ([P0]) are ignored. Anything else — free text, a single non-key=value token, invalid JSON, unbalanced brackets — yields no fields. Bounded per event: payloads over 4 KiB are skipped, at most 32 fields, over-long keys/values and repeated keys are dropped (first occurrence wins). 

|
static |
Returns the unit of an info field that starts with a [unit | partition] marker (e.g. "a-west" for [a-west | GP] Log message), else an empty view.


|
inlineoverridevirtual |
Gets the current parsing progress.
Implements parser::IDataParser.
|
inlineoverridevirtual |
The # Key : Value lines of the header block (before the first event), in file order, e.g. {"Test Case", "IL Grants A Movement Authority"}, {"Status", "PASS"}, {"Timestamp", …}, {"Sources", …}, {"Entries", "1129"}.
Reimplemented from parser::IDataParser.
|
inlineoverridevirtual |
Gets the total expected progress value.
Implements parser::IDataParser.
|
static |
True when the first lines of filepath carry the merged-log header (# FULL MERGED TEST STEPS, CONTAINER & SIMULATOR LOGS). Used to auto-select this parser for generic .txt files.

|
inlineinherited |
|
inlineinherited |

|
inlineinherited |

|
overridevirtual |
Parses data from a file path.
| filepath | The path to the file to parse |
| std::runtime_error | if the file cannot be opened or parsed |
Implements parser::IDataParser.

|
overridevirtual |
Parses data from an input stream.
| input | The input stream to read data from |
| std::runtime_error | if the stream cannot be read or parsed |
Implements parser::IDataParser.
|
static |
Appends a header line such as # Test Case : IL Grants … (starting with '#') to metadata as {"Test Case", "IL Grants …"}; other comment lines (rulers, the title line) are ignored.


|
static |
Parses one line into out. Returns false for header, blank and malformed lines. Exposed for tests.


|
private |

|
inlineinherited |
Registers an observer to receive parsing notifications.
| observer | Pointer to the observer object |
|
inlineinherited |
|
private |
|
private |
|
private |
|
privateinherited |