// Copyright (c) 2012-2024 Wojciech Figat. All rights reserved.
#pragma once
#include "Engine/Core/Log.h"
#include "Engine/Scripting/ManagedCLR/MTypes.h"
///
/// Utility class to manage debug and log messages transportation from/to managed/unmanaged data and sending them to log file.
///
class FLAXENGINE_API DebugLog
{
public:
///
/// Sends the log message to the Flax console and the log file.
///
/// The message type.
/// The message.
static void Log(LogType type, const StringView& message);
///
/// A variant of Debug.Log that logs a warning message to the console.
///
/// The text message to display.
FORCE_INLINE static void Log(const StringView& message)
{
Log(LogType::Info, message);
}
///
/// A variant of Debug.Log that logs a warning message to the console.
///
/// The text message to display.
FORCE_INLINE static void LogWarning(const StringView& message)
{
Log(LogType::Warning, message);
}
///
/// A variant of Debug.Log that logs a error message to the console.
///
/// The text message to display.
FORCE_INLINE static void LogError(const StringView& message)
{
Log(LogType::Error, message);
}
///
/// Logs a formatted exception message to the Flax Console.
///
/// Runtime Exception.
static void LogException(MObject* exceptionObject);
public:
///
/// Gets the managed stack trace.
///
/// The stack trace text.
static String GetStackTrace();
///
/// Throws the exception to the managed world. Can be called only during internal call from the C# world.
///
/// The message.
NO_RETURN static void ThrowException(const char* msg);
///
/// Throws the null reference to the managed world. Can be called only during internal call from the C# world.
///
NO_RETURN static void ThrowNullReference();
///
/// Throws the argument exception to the managed world. Can be called only during internal call from the C# world.
///
/// The argument name.
/// The message.
NO_RETURN static void ThrowArgument(const char* arg, const char* msg);
///
/// Throws the argument null to the managed world. Can be called only during internal call from the C# world.
///
/// The argument name.
NO_RETURN static void ThrowArgumentNull(const char* arg);
///
/// Throws the argument out of range to the managed world. Can be called only during internal call from the C# world.
///
/// The argument name.
NO_RETURN static void ThrowArgumentOutOfRange(const char* arg);
///
/// Throws the not supported operation exception to the managed world. Can be called only during internal call from the C# world.
///
/// The message.
NO_RETURN static void ThrowNotSupported(const char* msg);
};