Index: /cpp/common/log.cpp
===================================================================
--- /cpp/common/log.cpp	(revision 873)
+++ /cpp/common/log.cpp	(revision 874)
@@ -1,4 +1,4 @@
 // This file is a part of Framsticks SDK.  http://www.framsticks.com/
-// Copyright (C) 1999-2015  Maciej Komosinski and Szymon Ulatowski.
+// Copyright (C) 1999-2019  Maciej Komosinski and Szymon Ulatowski.
 // See LICENSE.txt for details.
 
@@ -8,5 +8,5 @@
 #include "Convert.h"
 
-const char* LOG_LEVEL[] = { "[DEBUG] ", "", "[WARN] ", "[ERROR] ", "[CRITICAL] " };
+const char* LOG_LEVEL_ARRAY[] = { "[DEBUG] ", "", "[WARN] ", "[ERROR] ", "[CRITICAL] " };
 
 void logPrintf_va(const char *obj, const char *method, int level, const char *msgf, va_list va)
@@ -31,2 +31,8 @@
 	va_end(argptr);
 }
+
+const char* logLevelName(int level)
+{
+	level = min(LOG_CRITICAL, max(LOG_DEBUG, level));
+	return LOG_LEVEL_ARRAY[level + 1];
+}
Index: /cpp/common/log.h
===================================================================
--- /cpp/common/log.h	(revision 873)
+++ /cpp/common/log.h	(revision 874)
@@ -1,4 +1,4 @@
 // This file is a part of Framsticks SDK.  http://www.framsticks.com/
-// Copyright (C) 1999-2015  Maciej Komosinski and Szymon Ulatowski.
+// Copyright (C) 1999-2019  Maciej Komosinski and Szymon Ulatowski.
 // See LICENSE.txt for details.
 
@@ -8,8 +8,7 @@
 #include <stdarg.h>
 
-extern const char* LOG_LEVEL[];
+extern const char* LOG_LEVEL_ARRAY[];
 #define LOG_FORMAT "%s%s.%s: %s"
 #define LOG_MULTILINE_CONTINUATION "..."
-
 
 void logPrintf(const char *obj, const char *method, int level, const char *msgf, ...);
@@ -17,4 +16,5 @@
 void log_printf(const char *msgf, ...); //a shorthand for printf (a different name again to avoid the risk of confusion with the two functions above. This would be unlikely but possible when the argument types would match)
 void logMessage(const char *obj, const char *method, int level, const char *msg);
+const char* logLevelName(int level);
 
 
Index: /cpp/common/loggers/loggers.cpp
===================================================================
--- /cpp/common/loggers/loggers.cpp	(revision 873)
+++ /cpp/common/loggers/loggers.cpp	(revision 874)
@@ -1,4 +1,4 @@
 // This file is a part of Framsticks SDK.  http://www.framsticks.com/
-// Copyright (C) 1999-2015  Maciej Komosinski and Szymon Ulatowski.
+// Copyright (C) 1999-2019  Maciej Komosinski and Szymon Ulatowski.
 // See LICENSE.txt for details.
 
@@ -148,5 +148,5 @@
 			{
 				if (msgs.length() > 0) msgs += '\n';
-				msgs += ssprintf(LOG_FORMAT, LOG_LEVEL[level + 1], obj, method, msg);
+				msgs += ssprintf(LOG_FORMAT, logLevelName(level), obj, method, msg);
 			}
 		}
@@ -170,3 +170,2 @@
 	return string("");
 }
-
Index: /cpp/common/loggers/loggertostdout.cpp
===================================================================
--- /cpp/common/loggers/loggertostdout.cpp	(revision 873)
+++ /cpp/common/loggers/loggertostdout.cpp	(revision 874)
@@ -1,4 +1,4 @@
 // This file is a part of Framsticks SDK.  http://www.framsticks.com/
-// Copyright (C) 1999-2015  Maciej Komosinski and Szymon Ulatowski.
+// Copyright (C) 1999-2019  Maciej Komosinski and Szymon Ulatowski.
 // See LICENSE.txt for details.
 
@@ -15,5 +15,5 @@
 
 const char** LoggerToStdout::default_log_level[] =
-{ LOG_LEVEL, default_log_level_ansicolor };
+{ LOG_LEVEL_ARRAY, default_log_level_ansicolor };
 
 const char* LoggerToStdout::default_log_format[] = //note trailing %s (so it's easy to append "\n" later)
@@ -29,12 +29,14 @@
 void LoggerToStdout::handleSingleLine(const char *obj, const char *method, int level, const char *msg)
 {
-	if (level < -1) level = -1; else if (level>3) level = 3;
 #ifdef SHP
-	AppLog(LOG_FORMAT "\n",LOG_LEVEL[level+1],obj,method,msg);
+	AppLog(LOG_FORMAT "\n", logLevelName(level), obj, method, msg);
 #else
 	if (file)
-		file->printf(LOG_FORMAT "\n", LOG_LEVEL[level + 1], obj, method, msg);
+		file->printf(LOG_FORMAT "\n", logLevelName(level), obj, method, msg);
 	else
+	{
+		if (level < -1) level = -1; else if (level > 3) level = 3;
 		printf(log_format, log_level[level + 1], obj, method, msg, "\n");
+	}
 #endif
 }
