From b9b25dc52ad73f1be70f42d649b7b52bc4807208 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 23 Aug 2025 17:24:48 +0100 Subject: Store the entities for each log line --- src/ingestor.cpp | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) (limited to 'src/ingestor.cpp') diff --git a/src/ingestor.cpp b/src/ingestor.cpp index 4084d2e..a3c49e7 100644 --- a/src/ingestor.cpp +++ b/src/ingestor.cpp @@ -71,17 +71,35 @@ namespace WebStat { { while (auto line = scn::scan(input, "{:[^\n]}\n")) { linesRead++; - if (auto result = scanLogLine(line->value())) { - linesParsed++; - std::ignore = result->values(); - } - else { - syslog(LOG_WARNING, "Discarded line: [%s]", line->value().c_str()); - linesDiscarded++; - } + ingestLogLine(line->value()); } } + void + Ingestor::ingestLogLine(const std::string_view line) + { + if (auto result = scanLogLine(line)) { + linesParsed++; + const auto values = crc32ScanValues(result->values()); + storeEntities(values); + } + else { + syslog(LOG_WARNING, "Discarded line: [%.*s]", static_cast(line.length()), line.data()); + linesDiscarded++; + } + } + + template + void + Ingestor::storeEntities(const std::tuple & values) const + { + std::apply( + [this](auto &&... value) { + (this->storeEntity(value), ...); + }, + values); + } + template void Ingestor::storeEntity(const T &) const -- cgit v1.2.3