summaryrefslogtreecommitdiffstats
path: root/src/Root.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Root.cpp')
-rw-r--r--src/Root.cpp26
1 files changed, 18 insertions, 8 deletions
diff --git a/src/Root.cpp b/src/Root.cpp
index c20cf0d21..ee0d9b835 100644
--- a/src/Root.cpp
+++ b/src/Root.cpp
@@ -18,6 +18,7 @@
#include "CommandOutput.h"
#include "DeadlockDetect.h"
#include "OSSupport/Timer.h"
+#include "LoggerListeners.h"
#include "inifile/iniFile.h"
@@ -51,7 +52,6 @@ cRoot::cRoot(void) :
m_FurnaceRecipe(NULL),
m_WebAdmin(NULL),
m_PluginManager(NULL),
- m_Log(NULL),
m_bStop(false),
m_bRestart(false)
{
@@ -105,10 +105,15 @@ void cRoot::Start(void)
HMENU hmenu = GetSystemMenu(hwnd, FALSE);
EnableMenuItem(hmenu, SC_CLOSE, MF_GRAYED); // Disable close button when starting up; it causes problems with our CTRL-CLOSE handling
#endif
+
+ cLogger::cListener * consoleLogListener = MakeConsoleListener();
+ cLogger::cListener * fileLogListener = new cFileListener();
+ cLogger::GetInstance().AttachListener(consoleLogListener);
+ cLogger::GetInstance().AttachListener(fileLogListener);
+
+ LOG("--- Started Log ---\n");
cDeadlockDetect dd;
- delete m_Log;
- m_Log = new cMCLogger();
m_bStop = false;
while (!m_bStop)
@@ -249,8 +254,13 @@ void cRoot::Start(void)
delete m_Server; m_Server = NULL;
LOG("Shutdown successful!");
}
-
- delete m_Log; m_Log = NULL;
+
+ LOG("--- Stopped Log ---");
+
+ cLogger::GetInstance().DetachListener(consoleLogListener);
+ delete consoleLogListener;
+ cLogger::GetInstance().DetachListener(fileLogListener);
+ delete fileLogListener;
}
@@ -274,15 +284,15 @@ void cRoot::LoadWorlds(cIniFile & IniFile)
m_WorldsByName[ DefaultWorldName ] = m_pDefaultWorld;
// Then load the other worlds
- unsigned int KeyNum = IniFile.FindKey("Worlds");
- unsigned int NumWorlds = IniFile.GetNumValues(KeyNum);
+ int KeyNum = IniFile.FindKey("Worlds");
+ int NumWorlds = IniFile.GetNumValues(KeyNum);
if (NumWorlds <= 0)
{
return;
}
bool FoundAdditionalWorlds = false;
- for (unsigned int i = 0; i < NumWorlds; i++)
+ for (int i = 0; i < NumWorlds; i++)
{
AString ValueName = IniFile.GetValueName(KeyNum, i);
if (ValueName.compare("World") != 0)