summaryrefslogtreecommitdiffstats
path: root/src/Root.cpp
diff options
context:
space:
mode:
authortycho <work.tycho@gmail.com>2015-08-30 23:57:43 +0200
committertycho <work.tycho@gmail.com>2015-09-15 17:19:49 +0200
commit3187dbf0aa0943d9eca0c5c1259f8a8ca549709b (patch)
tree82d3aaa2905d360779ea472bc3baf91f8539758b /src/Root.cpp
parentMerge pull request #2473 from cuberite/APIDumpRename (diff)
downloadcuberite-3187dbf0aa0943d9eca0c5c1259f8a8ca549709b.tar
cuberite-3187dbf0aa0943d9eca0c5c1259f8a8ca549709b.tar.gz
cuberite-3187dbf0aa0943d9eca0c5c1259f8a8ca549709b.tar.bz2
cuberite-3187dbf0aa0943d9eca0c5c1259f8a8ca549709b.tar.lz
cuberite-3187dbf0aa0943d9eca0c5c1259f8a8ca549709b.tar.xz
cuberite-3187dbf0aa0943d9eca0c5c1259f8a8ca549709b.tar.zst
cuberite-3187dbf0aa0943d9eca0c5c1259f8a8ca549709b.zip
Diffstat (limited to '')
-rw-r--r--src/Root.cpp19
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;
}