diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2025-08-23 17:28:37 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2025-08-25 16:02:41 +0100 |
commit | 7ec58bf3f72fd7e0396a37f43ff023731697ff8a (patch) | |
tree | 067bea2150c1efc9423d06e784cd0a19f29f3397 /src/ingestor.cpp | |
parent | b9b25dc52ad73f1be70f42d649b7b52bc4807208 (diff) | |
download | webstat-7ec58bf3f72fd7e0396a37f43ff023731697ff8a.tar.bz2 webstat-7ec58bf3f72fd7e0396a37f43ff023731697ff8a.tar.xz webstat-7ec58bf3f72fd7e0396a37f43ff023731697ff8a.zip |
Store log lines in full using entity ids
Diffstat (limited to 'src/ingestor.cpp')
-rw-r--r-- | src/ingestor.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
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 <connection.h> +#include <dbTypes.h> #include <modifycommand.h> #include <scn/scan.h> #include <syslog.h> #include <utility> #include <zlib.h> +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<int>(line.length()), line.data()); @@ -122,4 +133,21 @@ namespace WebStat { storeEntity(*entity); } } + + template<typename... T> + void + Ingestor::storeLogLine(const std::tuple<T...> & 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(); + } } |