diff options
author | Mattes D <github@xoft.cz> | 2015-09-16 09:12:56 +0200 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2015-09-16 09:12:56 +0200 |
commit | d041057da239d6dca02306849bd62973f3a51c62 (patch) | |
tree | 82d3aaa2905d360779ea472bc3baf91f8539758b /src/Root.cpp | |
parent | Merge pull request #2473 from cuberite/APIDumpRename (diff) | |
parent | Increase robustness of the logging subsystem (diff) | |
download | cuberite-d041057da239d6dca02306849bd62973f3a51c62.tar cuberite-d041057da239d6dca02306849bd62973f3a51c62.tar.gz cuberite-d041057da239d6dca02306849bd62973f3a51c62.tar.bz2 cuberite-d041057da239d6dca02306849bd62973f3a51c62.tar.lz cuberite-d041057da239d6dca02306849bd62973f3a51c62.tar.xz cuberite-d041057da239d6dca02306849bd62973f3a51c62.tar.zst cuberite-d041057da239d6dca02306849bd62973f3a51c62.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Root.cpp | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/Root.cpp b/src/Root.cpp index dc90671fb..13166d883 100644 --- a/src/Root.cpp +++ b/src/Root.cpp @@ -22,6 +22,7 @@ #include "SettingsRepositoryInterface.h" #include "OverridesSettingsRepository.h" #include "SelfTests.h" +#include "Logger.h" #include <iostream> @@ -107,10 +108,15 @@ void cRoot::Start(std::unique_ptr<cSettingsRepositoryInterface> a_OverridesRepo) EnableMenuItem(ConsoleMenu, SC_CLOSE, MF_GRAYED); // Disable close button when starting up; it causes problems with our CTRL-CLOSE handling #endif - cLogger::cListener * consoleLogListener = MakeConsoleListener(m_RunAsService); - cLogger::cListener * fileLogListener = new cFileListener(); - cLogger::GetInstance().AttachListener(consoleLogListener); - cLogger::GetInstance().AttachListener(fileLogListener); + auto consoleLogListener = MakeConsoleListener(m_RunAsService); + auto consoleAttachment = cLogger::GetInstance().AttachListener(std::move(consoleLogListener)); + auto fileLogListenerRet = MakeFileListener(); + if (!fileLogListenerRet.first) + { + LOGERROR("Failed to open log file, aborting"); + return; + } + auto fileAttachment = cLogger::GetInstance().AttachListener(std::move(fileLogListenerRet.second)); LOG("--- Started Log ---"); @@ -317,11 +323,6 @@ void cRoot::Start(std::unique_ptr<cSettingsRepositoryInterface> a_OverridesRepo) LOG("Shutdown successful - restarting..."); } LOG("--- Stopped Log ---"); - - cLogger::GetInstance().DetachListener(consoleLogListener); - delete consoleLogListener; - cLogger::GetInstance().DetachListener(fileLogListener); - delete fileLogListener; } |