|
LogViewer
A modern log viewer with AI-assisted analysis (Qt 6)
|
#include <JsonParser.hpp>


Public Member Functions | |
| JsonParser ()=default | |
| ~JsonParser () 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. | |
| virtual std::vector< std::pair< std::string, std::string > > | GetFileMetadata () const |
Ordered key → value pairs read from the file header during the last ParseData() call (see db::EventsContainer::SetFileMetadata). | |
| 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) |
Private Member Functions | |
| void | Flatten (const nlohmann::json &node, const std::string &prefix, db::LogEvent::EventItems &out) const |
Private Attributes | |
| uint32_t | m_currentProgress {0} |
| uint32_t | m_totalProgress {0} |
| std::vector< IDataParserObserver * > | observers |
Parses JSON log files in two formats:
Array — a single JSON array of objects at the top level. [ {"ts": "...", "level": "INFO", "msg": "..."}, ... ]
NDJSON — one JSON object per line (newline-delimited JSON / JSONL). {"ts": "...", "level": "INFO", "msg": "..."} {"ts": "...", "level": "WARN", "msg": "..."}
The format is detected automatically: the parser reads the first non-whitespace character; '[' means array mode, '{' means NDJSON mode.
Nested objects and arrays are flattened using dot-notation keys: { "ctx": { "user": "alice" } } → key "ctx.user" = "alice" { "tags": ["a","b"] } → key "tags.0" = "a", "tags.1" = "b"
|
default |
|
overridedefault |
|
private |


|
inlineoverridevirtual |
Gets the current parsing progress.
Implements parser::IDataParser.
|
inlinevirtualinherited |
Ordered key → value pairs read from the file header during the last ParseData() call (see db::EventsContainer::SetFileMetadata).
Reimplemented in parser::SapiLogParser.
|
inlineoverridevirtual |
Gets the total expected progress value.
Implements parser::IDataParser.
|
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.

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