aboutsummaryrefslogtreecommitdiff
path: root/src/logging.cpp
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/logging.cpp
parentImplement support for JSON logging. (diff)
Flush logs every 15 minutes to avoid losing data.
Diffstat (limited to 'src/logging.cpp')
-rw-r--r--src/logging.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/logging.cpp b/src/logging.cpp
index 37a38fae6..c5d295bd8 100644
--- a/src/logging.cpp
+++ b/src/logging.cpp
@@ -44,12 +44,16 @@ const char* Log::LevelToString(Log::Level level)
}
Log::FileMethod::FileMethod(const std::string& n, FILE* fh, unsigned long fl, bool ac)
- : autoclose(ac)
+ : Timer(15*60)
+ , autoclose(ac)
, file(fh)
, flush(fl)
, name(n)
{
+ if (flush > 1)
+ ServerInstance->Timers.AddTimer(this);
}
+
Log::FileMethod::~FileMethod()
{
if (autoclose)
@@ -84,6 +88,12 @@ void Log::FileMethod::OnLog(Level level, const std::string& type, const std::str
throw CoreException(InspIRCd::Format("Unable to write to %s: %s", name.c_str(), strerror(errno)));
}
+bool Log::FileMethod::Tick()
+{
+ fflush(file);
+ return true;
+}
+
Log::Engine::Engine(Module* Creator, const std::string& Name)
: DataProvider(Creator, "log/" + Name)
{