diff --git a/src/base/RunnersRegistry.h b/src/base/RunnersRegistry.h index 93a2294879b..52677fc997e 100644 --- a/src/base/RunnersRegistry.h +++ b/src/base/RunnersRegistry.h @@ -70,6 +70,16 @@ class RegisteredRunner /// Meant for adjusting the module state based on configuration changes. virtual void syncConfig() {} + /* Log Rotation events */ + + /// Called after receiving a log rotate request. + /// Meant for modules that manage log files to rename/rotate them. + virtual void rotateLogs() {} + + /// Called after rotating log files. + /// Meant for modules that need to (re-)attach to log files after rotation. + virtual void finishLogRotate() {} + /* Shutdown events */ /// Called after receiving a shutdown request and before stopping the main diff --git a/src/main.cc b/src/main.cc index c9ad17f905d..2bb05cfc580 100644 --- a/src/main.cc +++ b/src/main.cc @@ -944,6 +944,8 @@ mainRotate(void) if (AvoidSignalAction("log rotation", do_rotate)) return; + RunRegisteredHere(RegisteredRunner::rotateLogs); + icmpEngine.Close(); redirectShutdown(); #if USE_AUTH @@ -959,6 +961,9 @@ mainRotate(void) #if ICAP_CLIENT icapLogRotate(); /*icap.log*/ #endif + + RunRegisteredHere(RegisteredRunner::finishLogRotate); + icmpEngine.Open(); redirectInit(); #if USE_AUTH