From 420e164ea6d677c8a114427a350f1e17e86b9be0 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 12 Oct 2013 11:26:42 +0200 Subject: Fixed second logger constructor. --- source/MCLogger.cpp | 47 ++++++++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 19 deletions(-) (limited to 'source/MCLogger.cpp') diff --git a/source/MCLogger.cpp b/source/MCLogger.cpp index 2870d8ba1..4f3e5dc0f 100644 --- a/source/MCLogger.cpp +++ b/source/MCLogger.cpp @@ -37,24 +37,7 @@ cMCLogger::cMCLogger(void) { AString FileName; Printf(FileName, "LOG_%d.txt", (int)time(NULL)); - m_Log = new cLog(FileName); - m_Log->Log("--- Started Log ---\n"); - - s_MCLogger = this; - - #ifdef _WIN32 - // See whether we are writing to a console the default console attrib: - g_ShouldColorOutput = (_isatty(_fileno(stdin)) != 0); - if (g_ShouldColorOutput) - { - CONSOLE_SCREEN_BUFFER_INFO sbi; - GetConsoleScreenBufferInfo(g_Console, &sbi); - g_DefaultConsoleAttrib = sbi.wAttributes; - } - #elif defined (__linux) && !defined(ANDROID_NDK) - g_ShouldColorOutput = isatty(fileno(stdout)); - // TODO: Check if the terminal supports colors, somehow? - #endif + InitLog(FileName); } @@ -63,7 +46,7 @@ cMCLogger::cMCLogger(void) cMCLogger::cMCLogger(const AString & a_FileName) { - m_Log = new cLog(a_FileName); + InitLog(a_FileName); } @@ -84,6 +67,32 @@ cMCLogger::~cMCLogger() +void cMCLogger::InitLog(const AString & a_FileName) +{ + m_Log = new cLog(a_FileName); + m_Log->Log("--- Started Log ---\n"); + + s_MCLogger = this; + + #ifdef _WIN32 + // See whether we are writing to a console the default console attrib: + g_ShouldColorOutput = (_isatty(_fileno(stdin)) != 0); + if (g_ShouldColorOutput) + { + CONSOLE_SCREEN_BUFFER_INFO sbi; + GetConsoleScreenBufferInfo(g_Console, &sbi); + g_DefaultConsoleAttrib = sbi.wAttributes; + } + #elif defined (__linux) && !defined(ANDROID_NDK) + g_ShouldColorOutput = isatty(fileno(stdout)); + // TODO: Check if the terminal supports colors, somehow? + #endif +} + + + + + void cMCLogger::LogSimple(const char* a_Text, int a_LogType /* = 0 */ ) { switch( a_LogType ) -- cgit v1.2.3