diff options
author | electromatter <electromatter@gmail.com> | 2015-09-22 04:44:34 +0200 |
---|---|---|
committer | electromatter <electromatter@gmail.com> | 2015-09-22 04:44:34 +0200 |
commit | a24cc0184343416eed86b208d8a2aff2b5c0892c (patch) | |
tree | 04ced91aa4a70b4c6e033fac4a2fc2e2ea206205 /src/Root.cpp | |
parent | added bungeecord support for protocol18x (diff) | |
parent | Merge pull request #2488 from cuberite/ChatFlag (diff) | |
download | cuberite-a24cc0184343416eed86b208d8a2aff2b5c0892c.tar cuberite-a24cc0184343416eed86b208d8a2aff2b5c0892c.tar.gz cuberite-a24cc0184343416eed86b208d8a2aff2b5c0892c.tar.bz2 cuberite-a24cc0184343416eed86b208d8a2aff2b5c0892c.tar.lz cuberite-a24cc0184343416eed86b208d8a2aff2b5c0892c.tar.xz cuberite-a24cc0184343416eed86b208d8a2aff2b5c0892c.tar.zst cuberite-a24cc0184343416eed86b208d8a2aff2b5c0892c.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; } |