summaryrefslogtreecommitdiffstats
path: root/src/Log.cpp
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2014-01-29 20:22:03 +0100
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2014-01-29 20:22:03 +0100
commit7d03876a3e11aedff0201a8330bfdb2b5523fc5e (patch)
tree04f795a2ff37644aa47c0b0d86f648eec949fba3 /src/Log.cpp
parentFixed redstone simulator crash found in #570 (diff)
downloadcuberite-7d03876a3e11aedff0201a8330bfdb2b5523fc5e.tar
cuberite-7d03876a3e11aedff0201a8330bfdb2b5523fc5e.tar.gz
cuberite-7d03876a3e11aedff0201a8330bfdb2b5523fc5e.tar.bz2
cuberite-7d03876a3e11aedff0201a8330bfdb2b5523fc5e.tar.lz
cuberite-7d03876a3e11aedff0201a8330bfdb2b5523fc5e.tar.xz
cuberite-7d03876a3e11aedff0201a8330bfdb2b5523fc5e.tar.zst
cuberite-7d03876a3e11aedff0201a8330bfdb2b5523fc5e.zip
Diffstat (limited to 'src/Log.cpp')
-rw-r--r--src/Log.cpp31
1 files changed, 29 insertions, 2 deletions
diff --git a/src/Log.cpp b/src/Log.cpp
index 2d6be0f59..a23a79ccc 100644
--- a/src/Log.cpp
+++ b/src/Log.cpp
@@ -99,7 +99,7 @@ void cLog::ClearLog()
-void cLog::Log(const char * a_Format, va_list argList)
+void cLog::Log(const char * a_Format, va_list argList, bool a_ReplaceCurrentLine)
{
AString Message;
AppendVPrintf(Message, a_Format, argList);
@@ -134,7 +134,34 @@ void cLog::Log(const char * a_Format, va_list argList)
__android_log_print(ANDROID_LOG_ERROR, "MCServer", "%s", Line.c_str() );
//CallJavaFunction_Void_String(g_JavaThread, "AddToLog", Line );
#else
- printf("%s", Line.c_str());
+ if (a_ReplaceCurrentLine)
+ {
+#ifdef _WIN32
+ if (m_LastStringSize == 0)
+ {
+ m_LastStringSize = Line.length();
+ }
+ else if (Line.length() < m_LastStringSize) // If last printed line was longer than current, clear this line
+ {
+ for (size_t X = 0; X != m_LastStringSize; ++X)
+ {
+ fputs(" ", stdout);
+ }
+ }
+#else // _WIN32
+ fputs("\033[K", stdout); // Clear current line
+#endif
+
+ printf("\r%s", Line.c_str());
+
+#ifdef __linux
+ fputs("\033[1B", stdout); // Move down one line
+#endif // __linux
+ }
+ else
+ {
+ printf("%s", Line.c_str());
+ }
#endif
#if defined (_WIN32) && defined(_DEBUG)