diff options
| author | 2022-05-02 17:21:19 +0100 | |
|---|---|---|
| committer | 2022-05-02 17:21:19 +0100 | |
| commit | 21ad77d9f25bbdfa3fdeb653afaceb6532d6919b (patch) | |
| tree | 9142cfaacb428c313af8581d00681f9c9a14eb7d /src/logging.cpp | |
| parent | Implement 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.cpp | 12 |
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) { |
