From 7ec58bf3f72fd7e0396a37f43ff023731697ff8a Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 23 Aug 2025 17:28:37 +0100 Subject: Store log lines in full using entity ids --- src/ingestor.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/ingestor.cpp') diff --git a/src/ingestor.cpp b/src/ingestor.cpp index a3c49e7..c1206a2 100644 --- a/src/ingestor.cpp +++ b/src/ingestor.cpp @@ -1,12 +1,22 @@ #include "ingestor.hpp" #include "sql.hpp" #include +#include #include #include #include #include #include +namespace DB { + template<> + void + DB::Command::bindParam(unsigned int idx, const WebStat::Entity & entity) + { + bindParamI(idx, entity.first); + } +} + namespace WebStat { namespace { Crc32Value @@ -82,6 +92,7 @@ namespace WebStat { linesParsed++; const auto values = crc32ScanValues(result->values()); storeEntities(values); + storeLogLine(values); } else { syslog(LOG_WARNING, "Discarded line: [%.*s]", static_cast(line.length()), line.data()); @@ -122,4 +133,21 @@ namespace WebStat { storeEntity(*entity); } } + + template + void + Ingestor::storeLogLine(const std::tuple & values) const + { + auto insert = dbconn->modify(SQL::ACCESS_LOG_INSERT, SQL::ACCESS_LOG_INSERT_OPTS); + + insert->bindParam(0, hostnameId); + std::apply( + [&insert](auto &&... value) { + unsigned int param = 1; + (insert->bindParam(param++, value), ...); + }, + values); + + insert->execute(); + } } -- cgit v1.2.3