aboutsummaryrefslogtreecommitdiffstats
path: root/src/modules
diff options
context:
space:
mode:
authorGravatar Sadie Powell2022-05-02 17:21:19 +0100
committerGravatar Sadie Powell2022-05-02 17:21:19 +0100
commit21ad77d9f25bbdfa3fdeb653afaceb6532d6919b (patch)
tree9142cfaacb428c313af8581d00681f9c9a14eb7d /src/modules
parentImplement support for JSON logging. (diff)
downloadinspircd++-21ad77d9f25bbdfa3fdeb653afaceb6532d6919b.tar.gz
inspircd++-21ad77d9f25bbdfa3fdeb653afaceb6532d6919b.tar.bz2
inspircd++-21ad77d9f25bbdfa3fdeb653afaceb6532d6919b.zip
Flush logs every 15 minutes to avoid losing data.
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/extra/m_log_json.cpp12
1 files changed, 11 insertions, 1 deletions
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