From 806d0936dc94f235858ffe1772a6215f86c5d000 Mon Sep 17 00:00:00 2001 From: Tycho Date: Sun, 10 Aug 2014 19:34:11 +0100 Subject: First Implementatation of new Loggin framework --- src/Root.cpp | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'src/Root.cpp') diff --git a/src/Root.cpp b/src/Root.cpp index c20cf0d21..72048b631 100644 --- a/src/Root.cpp +++ b/src/Root.cpp @@ -18,6 +18,7 @@ #include "CommandOutput.h" #include "DeadlockDetect.h" #include "OSSupport/Timer.h" +#include "Listeners.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 + + Logger::cLoggerListener * consoleLogListener = Logger::MakeConsoleListener(); + Logger::cLoggerListener * fileLogListener = new Logger::cFileListener(); + Logger::GetInstance().AttachListener(consoleLogListener); + Logger::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 ---"); + + Logger::GetInstance().DetachListener(consoleLogListener); + delete consoleLogListener; + Logger::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) -- cgit v1.2.3 From 98443682671d0c39b19f86098f7bc900b7529b72 Mon Sep 17 00:00:00 2001 From: Tycho Date: Tue, 12 Aug 2014 16:05:04 +0100 Subject: Renamed Loggers --- src/Root.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/Root.cpp') diff --git a/src/Root.cpp b/src/Root.cpp index 72048b631..ee0d9b835 100644 --- a/src/Root.cpp +++ b/src/Root.cpp @@ -18,7 +18,7 @@ #include "CommandOutput.h" #include "DeadlockDetect.h" #include "OSSupport/Timer.h" -#include "Listeners.h" +#include "LoggerListeners.h" #include "inifile/iniFile.h" @@ -106,10 +106,10 @@ void cRoot::Start(void) EnableMenuItem(hmenu, SC_CLOSE, MF_GRAYED); // Disable close button when starting up; it causes problems with our CTRL-CLOSE handling #endif - Logger::cLoggerListener * consoleLogListener = Logger::MakeConsoleListener(); - Logger::cLoggerListener * fileLogListener = new Logger::cFileListener(); - Logger::GetInstance().AttachListener(consoleLogListener); - Logger::GetInstance().AttachListener(fileLogListener); + cLogger::cListener * consoleLogListener = MakeConsoleListener(); + cLogger::cListener * fileLogListener = new cFileListener(); + cLogger::GetInstance().AttachListener(consoleLogListener); + cLogger::GetInstance().AttachListener(fileLogListener); LOG("--- Started Log ---\n"); @@ -257,9 +257,9 @@ void cRoot::Start(void) LOG("--- Stopped Log ---"); - Logger::GetInstance().DetachListener(consoleLogListener); + cLogger::GetInstance().DetachListener(consoleLogListener); delete consoleLogListener; - Logger::GetInstance().DetachListener(fileLogListener); + cLogger::GetInstance().DetachListener(fileLogListener); delete fileLogListener; } -- cgit v1.2.3