diff options
Diffstat (limited to 'source/MCLogger.cpp')
-rw-r--r-- | source/MCLogger.cpp | 47 |
1 files changed, 28 insertions, 19 deletions
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 ) |