diff options
| author | Dan Goodliffe <dan@randomdan.homeip.net> | 2026-03-20 23:48:32 +0000 |
|---|---|---|
| committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2026-03-20 23:48:32 +0000 |
| commit | 05c47ab65e73b16887b7c7a1eb31acf6d364ef41 (patch) | |
| tree | 837a65e5460154a8c00c91519a8ea313445ad1dd /src/webstat_logger_main.cpp | |
| parent | 0f5a0a8e2d43774288d4d6ea747278ca6e085a2a (diff) | |
| download | webstat-05c47ab65e73b16887b7c7a1eb31acf6d364ef41.tar.bz2 webstat-05c47ab65e73b16887b7c7a1eb31acf6d364ef41.tar.xz webstat-05c47ab65e73b16887b7c7a1eb31acf6d364ef41.zip | |
Add logging :-o
Adds virtual log function, real implementation writes to syslog.
Test implementation writes to BOOST_TEST_MESSAGE, perf implementation
discards.
Replaces existing prints to stderr and adds logs to all key points.
Diffstat (limited to 'src/webstat_logger_main.cpp')
| -rw-r--r-- | src/webstat_logger_main.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/webstat_logger_main.cpp b/src/webstat_logger_main.cpp index 39d794a..3eaa9f0 100644 --- a/src/webstat_logger_main.cpp +++ b/src/webstat_logger_main.cpp @@ -5,6 +5,7 @@ #include <iostream> #include <pq-connection.h> #include <sys/utsname.h> +#include <syslog.h> namespace { [[nodiscard]] @@ -17,6 +18,19 @@ namespace { } return uts; } + + class MainIngestor : public WebStat::Ingestor { + using Ingestor::Ingestor; + + void + log(int level, const char * msgfmt, ...) const override + { + va_list args; + va_start(args, msgfmt); + vsyslog(level, msgfmt, args); + va_end(args); + } + }; } #define LEXICAL_CAST_DURATION(UNIT) \ @@ -87,7 +101,7 @@ main(int argc, char ** argv) po::notify(optVars); try { - WebStat::Ingestor {getHostDetail(), std::move(settings)}.ingestLog(stdin); + MainIngestor {getHostDetail(), std::move(settings)}.ingestLog(stdin); return EXIT_SUCCESS; } catch (const std::exception & excp) { |
