Clean up CServerLogger (fixes #6598)

This commit is contained in:
Dennis Felsing 2023-05-17 01:04:06 +02:00
parent daecca6c67
commit caa76249d8
3 changed files with 7 additions and 5 deletions

View file

@ -36,7 +36,7 @@ public:
virtual void Init() = 0; virtual void Init() = 0;
virtual void AddJob(std::shared_ptr<IJob> pJob) = 0; virtual void AddJob(std::shared_ptr<IJob> pJob) = 0;
virtual void SetAdditionalLogger(std::unique_ptr<ILogger> &&pLogger) = 0; virtual void SetAdditionalLogger(std::shared_ptr<ILogger> &&pLogger) = 0;
static void RunJobBlocking(IJob *pJob); static void RunJobBlocking(IJob *pJob);
}; };

View file

@ -182,7 +182,8 @@ int main(int argc, const char **argv)
dbg_msg("server", "failed to open '%s' for logging", g_Config.m_Logfile); dbg_msg("server", "failed to open '%s' for logging", g_Config.m_Logfile);
} }
} }
pEngine->SetAdditionalLogger(std::make_unique<CServerLogger>(pServer)); auto pServerLogger = std::make_shared<CServerLogger>(pServer);
pEngine->SetAdditionalLogger(pServerLogger);
// run the server // run the server
dbg_msg("server", "starting..."); dbg_msg("server", "starting...");
@ -191,6 +192,7 @@ int main(int argc, const char **argv)
MysqlUninit(); MysqlUninit();
secure_random_uninit(); secure_random_uninit();
pServerLogger->OnServerDeletion();
// free // free
delete pKernel; delete pKernel;

View file

@ -30,7 +30,7 @@ public:
IStorage *m_pStorage; IStorage *m_pStorage;
bool m_Logging; bool m_Logging;
std::shared_ptr<CFutureLogger> m_pFutureLogger; std::shared_ptr<ILogger> m_pFutureLogger;
char m_aAppName[256]; char m_aAppName[256];
@ -113,9 +113,9 @@ public:
m_JobPool.Add(std::move(pJob)); m_JobPool.Add(std::move(pJob));
} }
void SetAdditionalLogger(std::unique_ptr<ILogger> &&pLogger) override void SetAdditionalLogger(std::shared_ptr<ILogger> &&pLogger) override
{ {
m_pFutureLogger->Set(std::move(pLogger)); m_pFutureLogger = pLogger;
} }
}; };