From 21ad77d9f25bbdfa3fdeb653afaceb6532d6919b Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Mon, 2 May 2022 17:21:19 +0100 Subject: Flush logs every 15 minutes to avoid losing data. --- src/modules/extra/m_log_json.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/modules') diff --git a/src/modules/extra/m_log_json.cpp b/src/modules/extra/m_log_json.cpp index 1701a998c..c4394a0ae 100644 --- a/src/modules/extra/m_log_json.cpp +++ b/src/modules/extra/m_log_json.cpp @@ -26,6 +26,7 @@ class JSONMethod final : public Log::Method + , public Timer { private: // The file to which the log is written. @@ -45,10 +46,13 @@ public: typedef char Ch; JSONMethod(const std::string& n, FILE* fh, unsigned long fl) ATTR_NOT_NULL(3) - : file(fh) + : Timer(15*60) + , file(fh) , flush(fl) , name(n) { + if (flush > 1) + ServerInstance->Timers.AddTimer(this); } ~JSONMethod() @@ -105,6 +109,12 @@ public: { fputc(c, file); } + + bool Tick() override + { + fflush(file); + return true; + } }; class JSONEngine final -- cgit v1.3.1-10-gc9f91