diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2025-08-23 17:24:48 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2025-08-25 16:02:39 +0100 |
commit | b9b25dc52ad73f1be70f42d649b7b52bc4807208 (patch) | |
tree | 7695bc342e8222e3e855afc740daf24b7d8bb102 /src/ingestor.cpp | |
parent | b446381dfa3f4298262ad8c7ef942d4ec64bcbea (diff) | |
download | webstat-b9b25dc52ad73f1be70f42d649b7b52bc4807208.tar.bz2 webstat-b9b25dc52ad73f1be70f42d649b7b52bc4807208.tar.xz webstat-b9b25dc52ad73f1be70f42d649b7b52bc4807208.zip |
Store the entities for each log line
Diffstat (limited to 'src/ingestor.cpp')
-rw-r--r-- | src/ingestor.cpp | 34 |
1 files changed, 26 insertions, 8 deletions
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<std::string>(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<int>(line.length()), line.data()); + linesDiscarded++; + } + } + + template<typename... T> + void + Ingestor::storeEntities(const std::tuple<T...> & values) const + { + std::apply( + [this](auto &&... value) { + (this->storeEntity(value), ...); + }, + values); + } + template<typename T> void Ingestor::storeEntity(const T &) const |