diff --git a/Source/Engine/Core/Log.cpp b/Source/Engine/Core/Log.cpp
index 8241097b1..30f838371 100644
--- a/Source/Engine/Core/Log.cpp
+++ b/Source/Engine/Core/Log.cpp
@@ -116,7 +116,7 @@ bool Log::Logger::Init()
return false;
}
-void Log::Logger::Write(const StringView& msg)
+void Log::Logger::Write(const StringView& msg, LogType type)
{
const auto ptr = msg.Get();
const auto length = msg.Length();
@@ -152,7 +152,7 @@ void Log::Logger::Write(const StringView& msg)
#if !BUILD_RELEASE
// Send message to platform logging
- Platform::Log(msg);
+ Platform::Log(msg, (int32)type);
#endif
// Write message to log file
@@ -270,7 +270,7 @@ void Log::Logger::Write(LogType type, const StringView& msg)
ProcessLogMessage(type, msg, w);
// Log formatted message
- Write(StringView(w.data(), (int32)w.size()));
+ Write(StringView(w.data(), (int32)w.size()), type);
// Fire events
OnMessage(type, msg);
diff --git a/Source/Engine/Core/Log.h b/Source/Engine/Core/Log.h
index e10fc50a0..bb0c4fc62 100644
--- a/Source/Engine/Core/Log.h
+++ b/Source/Engine/Core/Log.h
@@ -177,7 +177,8 @@ namespace Log
/// Writes a custom message to the log.
///
/// The message text.
- static void Write(const StringView& msg);
+ /// The message type.
+ static void Write(const StringView& msg, LogType type = LogType::Info);
///
/// Writes an exception formatted message to log file.
diff --git a/Source/Engine/Platform/Android/AndroidPlatform.cpp b/Source/Engine/Platform/Android/AndroidPlatform.cpp
index 2f4577877..0e2f9e686 100644
--- a/Source/Engine/Platform/Android/AndroidPlatform.cpp
+++ b/Source/Engine/Platform/Android/AndroidPlatform.cpp
@@ -992,11 +992,16 @@ void AndroidPlatform::Exit()
#if !BUILD_RELEASE
-void AndroidPlatform::Log(const StringView& msg)
+void AndroidPlatform::Log(const StringView& msg, int32 logType)
{
const StringAsANSI<512> msgAnsi(*msg, msg.Length());
const char* str = msgAnsi.Get();
- __android_log_write(ANDROID_LOG_INFO, "Flax", str);
+ int prio = ANDROID_LOG_INFO;
+ if (logType == (int32)LogType::Warning)
+ prio = ANDROID_LOG_WARN;
+ if (logType == (int32)LogType::Error)
+ prio = ANDROID_LOG_ERROR;
+ __android_log_write(prio, "Flax", str);
}
#endif
diff --git a/Source/Engine/Platform/Android/AndroidPlatform.h b/Source/Engine/Platform/Android/AndroidPlatform.h
index b55deadd9..408dcef47 100644
--- a/Source/Engine/Platform/Android/AndroidPlatform.h
+++ b/Source/Engine/Platform/Android/AndroidPlatform.h
@@ -108,7 +108,7 @@ public:
static void BeforeExit();
static void Exit();
#if !BUILD_RELEASE
- static void Log(const StringView& msg);
+ static void Log(const StringView& msg, int32 logType = 1);
#endif
static int32 GetDpi();
static NetworkConnectionType GetNetworkConnectionType();
diff --git a/Source/Engine/Platform/Apple/ApplePlatform.cpp b/Source/Engine/Platform/Apple/ApplePlatform.cpp
index 6827e7ac6..49b484ac6 100644
--- a/Source/Engine/Platform/Apple/ApplePlatform.cpp
+++ b/Source/Engine/Platform/Apple/ApplePlatform.cpp
@@ -361,7 +361,7 @@ void ApplePlatform::GetUTCTime(int32& year, int32& month, int32& dayOfWeek, int3
#if !BUILD_RELEASE
-void ApplePlatform::Log(const StringView& msg)
+void ApplePlatform::Log(const StringView& msg, int32 logType)
{
#if !USE_EDITOR
NSLog(@"%s", StringAsANSI<>(*msg, msg.Length()).Get());
diff --git a/Source/Engine/Platform/Apple/ApplePlatform.h b/Source/Engine/Platform/Apple/ApplePlatform.h
index 04af9757b..ca4e2614d 100644
--- a/Source/Engine/Platform/Apple/ApplePlatform.h
+++ b/Source/Engine/Platform/Apple/ApplePlatform.h
@@ -82,7 +82,7 @@ public:
static void GetSystemTime(int32& year, int32& month, int32& dayOfWeek, int32& day, int32& hour, int32& minute, int32& second, int32& millisecond);
static void GetUTCTime(int32& year, int32& month, int32& dayOfWeek, int32& day, int32& hour, int32& minute, int32& second, int32& millisecond);
#if !BUILD_RELEASE
- static void Log(const StringView& msg);
+ static void Log(const StringView& msg, int32 logType = 1);
static bool IsDebuggerPresent();
#endif
static bool Init();
diff --git a/Source/Engine/Platform/Base/PlatformBase.cpp b/Source/Engine/Platform/Base/PlatformBase.cpp
index 7cae77c3b..7e5b99e60 100644
--- a/Source/Engine/Platform/Base/PlatformBase.cpp
+++ b/Source/Engine/Platform/Base/PlatformBase.cpp
@@ -521,7 +521,7 @@ void PlatformBase::Fatal(const StringView& msg, FatalErrorType error)
Fatal(msg, nullptr, error);
}
-void PlatformBase::Log(const StringView& msg)
+void PlatformBase::Log(const StringView& msg, int32 logType)
{
}
diff --git a/Source/Engine/Platform/Base/PlatformBase.h b/Source/Engine/Platform/Base/PlatformBase.h
index f8e072f2f..904178693 100644
--- a/Source/Engine/Platform/Base/PlatformBase.h
+++ b/Source/Engine/Platform/Base/PlatformBase.h
@@ -540,7 +540,8 @@ public:
/// Logs the specified message to the platform-dependant logging stream.
///
/// The message.
- static void Log(const StringView& msg);
+ /// The type of the log matching LogType enum. 1 - log, 2 - warning, 4 - error
+ static void Log(const StringView& msg, int32 logType = 1);
///
/// Checks whenever program is running with debugger attached.
diff --git a/Source/Engine/Platform/GDK/GDKPlatform.cpp b/Source/Engine/Platform/GDK/GDKPlatform.cpp
index 969f24934..092c4037b 100644
--- a/Source/Engine/Platform/GDK/GDKPlatform.cpp
+++ b/Source/Engine/Platform/GDK/GDKPlatform.cpp
@@ -483,7 +483,7 @@ void GDKPlatform::Exit()
#if !BUILD_RELEASE
-void GDKPlatform::Log(const StringView& msg)
+void GDKPlatform::Log(const StringView& msg, int32 logType)
{
Char buffer[512];
Char* str;
diff --git a/Source/Engine/Platform/GDK/GDKPlatform.h b/Source/Engine/Platform/GDK/GDKPlatform.h
index e2c23dbf3..26dbd852b 100644
--- a/Source/Engine/Platform/GDK/GDKPlatform.h
+++ b/Source/Engine/Platform/GDK/GDKPlatform.h
@@ -57,7 +57,7 @@ public:
static void BeforeExit();
static void Exit();
#if !BUILD_RELEASE
- static void Log(const StringView& msg);
+ static void Log(const StringView& msg, int32 logType = 1);
static bool IsDebuggerPresent();
#endif
static String GetSystemName();
diff --git a/Source/Engine/Platform/Web/WebPlatform.cpp b/Source/Engine/Platform/Web/WebPlatform.cpp
index cbe4325ea..863f8ea30 100644
--- a/Source/Engine/Platform/Web/WebPlatform.cpp
+++ b/Source/Engine/Platform/Web/WebPlatform.cpp
@@ -149,9 +149,7 @@ void WebPlatform::GetUTCTime(int32& year, int32& month, int32& dayOfWeek, int32&
millisecond = (int64)(emscripten_get_now() - DateStart) % 1000; // Fake it based on other timer
}
-#if !BUILD_RELEASE
-
-void WebPlatform::Log(const StringView& msg)
+void WebPlatform::Log(const StringView& msg, int32 logType)
{
const StringAsANSI<512> msgAnsi(*msg, msg.Length());
@@ -163,9 +161,16 @@ void WebPlatform::Log(const StringView& msg)
buffer[i] = 'p';
}
- emscripten_log(EM_LOG_CONSOLE, buffer);
+ int flags = EM_LOG_CONSOLE;
+ if (logType == (int32)LogType::Warning)
+ flags |= EM_LOG_WARN;
+ if (logType == (int32)LogType::Error)
+ flags |= EM_LOG_ERROR;
+ emscripten_log(flags, buffer);
}
+#if !BUILD_RELEASE
+
bool WebPlatform::IsDebuggerPresent()
{
return false;
diff --git a/Source/Engine/Platform/Web/WebPlatform.h b/Source/Engine/Platform/Web/WebPlatform.h
index 73b8588b8..da01f9662 100644
--- a/Source/Engine/Platform/Web/WebPlatform.h
+++ b/Source/Engine/Platform/Web/WebPlatform.h
@@ -93,8 +93,8 @@ public:
static uint64 GetTimeCycles();
static void GetSystemTime(int32& year, int32& month, int32& dayOfWeek, int32& day, int32& hour, int32& minute, int32& second, int32& millisecond);
static void GetUTCTime(int32& year, int32& month, int32& dayOfWeek, int32& day, int32& hour, int32& minute, int32& second, int32& millisecond);
+ static void Log(const StringView& msg, int32 logType = 1);
#if !BUILD_RELEASE
- static void Log(const StringView& msg);
static bool IsDebuggerPresent();
#endif
static String GetComputerName();
diff --git a/Source/Engine/Platform/Windows/WindowsPlatform.cpp b/Source/Engine/Platform/Windows/WindowsPlatform.cpp
index cc339c9e9..ac4809b53 100644
--- a/Source/Engine/Platform/Windows/WindowsPlatform.cpp
+++ b/Source/Engine/Platform/Windows/WindowsPlatform.cpp
@@ -874,7 +874,7 @@ void WindowsPlatform::Exit()
#if !BUILD_RELEASE
-void WindowsPlatform::Log(const StringView& msg)
+void WindowsPlatform::Log(const StringView& msg, int32 logType)
{
Char buffer[512];
Char* str;
diff --git a/Source/Engine/Platform/Windows/WindowsPlatform.h b/Source/Engine/Platform/Windows/WindowsPlatform.h
index a30e3e145..d45dd237c 100644
--- a/Source/Engine/Platform/Windows/WindowsPlatform.h
+++ b/Source/Engine/Platform/Windows/WindowsPlatform.h
@@ -58,7 +58,7 @@ public:
static void BeforeExit();
static void Exit();
#if !BUILD_RELEASE
- static void Log(const StringView& msg);
+ static void Log(const StringView& msg, int32 logType = 1);
static bool IsDebuggerPresent();
#endif
static void SetHighDpiAwarenessEnabled(bool enable);