diff --git a/src/AccessLogEntry.h b/src/AccessLogEntry.h index ec07698294f..c53e8a6f724 100644 --- a/src/AccessLogEntry.h +++ b/src/AccessLogEntry.h @@ -32,11 +32,45 @@ #include "ssl/support.h" #endif +#include + /* forward decls */ class HttpReply; class HttpRequest; class CustomLog; +// TODO: move +/// Accumulates timings of message IO events. +class MessageTimer +{ +public: + using Clock = std::chrono::system_clock; + using Time = Clock::time_point; + + MessageTimer() = default; + explicit MessageTimer(const Time &s) : first(s), last(s) {} + + /// sets firstTime (if uninitialized yet) and lastTime (always) to the current time + void update() { + last = Clock::now(); + if (!first) + first = last; + } + + /// removes firstTime and lastTime values + void reset() { *this = MessageTimer(); } + + /// the time of the first IO for the message + auto firstTime() const { return first; } + + /// the time of the last IO for the message + auto lastTime() const { return last; } + +private: + std::optional