Add verbosity level to platform log for better integration with Web and Android platforms
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -177,7 +177,8 @@ namespace Log
|
||||
/// Writes a custom message to the log.
|
||||
/// </summary>
|
||||
/// <param name="msg">The message text.</param>
|
||||
static void Write(const StringView& msg);
|
||||
/// <param name="type">The message type.</param>
|
||||
static void Write(const StringView& msg, LogType type = LogType::Info);
|
||||
|
||||
/// <summary>
|
||||
/// Writes an exception formatted message to log file.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -540,7 +540,8 @@ public:
|
||||
/// Logs the specified message to the platform-dependant logging stream.
|
||||
/// </summary>
|
||||
/// <param name="msg">The message.</param>
|
||||
static void Log(const StringView& msg);
|
||||
/// <param name="logType">The type of the log matching LogType enum. 1 - log, 2 - warning, 4 - error</param>
|
||||
static void Log(const StringView& msg, int32 logType = 1);
|
||||
|
||||
/// <summary>
|
||||
/// Checks whenever program is running with debugger attached.
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user