diff options
author | madmaxoft <github@xoft.cz> | 2013-10-12 11:26:42 +0200 |
---|---|---|
committer | madmaxoft <github@xoft.cz> | 2013-10-12 11:26:42 +0200 |
commit | 420e164ea6d677c8a114427a350f1e17e86b9be0 (patch) | |
tree | c409d86898d792cfebe9d1e4f87f2908114fd31c /source/MCLogger.cpp | |
parent | Updated BiomeVisualiser to compile again. (diff) | |
download | cuberite-420e164ea6d677c8a114427a350f1e17e86b9be0.tar cuberite-420e164ea6d677c8a114427a350f1e17e86b9be0.tar.gz cuberite-420e164ea6d677c8a114427a350f1e17e86b9be0.tar.bz2 cuberite-420e164ea6d677c8a114427a350f1e17e86b9be0.tar.lz cuberite-420e164ea6d677c8a114427a350f1e17e86b9be0.tar.xz cuberite-420e164ea6d677c8a114427a350f1e17e86b9be0.tar.zst cuberite-420e164ea6d677c8a114427a350f1e17e86b9be0.zip |
Diffstat (limited to '')
-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 ) |