fix: refine editor console logging

This commit is contained in:
2026-04-05 02:26:21 +08:00
parent cb7d60ec13
commit 811958351e
4 changed files with 123 additions and 68 deletions

View File

@@ -1,20 +1,34 @@
using System.Runtime.CompilerServices;
namespace XCEngine
{
public static class Debug
{
public static void Log(string message)
public static void Log(
string message,
[CallerFilePath] string file = "",
[CallerLineNumber] int line = 0,
[CallerMemberName] string member = "")
{
InternalCalls.Debug_Log(message ?? string.Empty);
InternalCalls.Debug_Log(message ?? string.Empty, file ?? string.Empty, line, member ?? string.Empty);
}
public static void LogWarning(string message)
public static void LogWarning(
string message,
[CallerFilePath] string file = "",
[CallerLineNumber] int line = 0,
[CallerMemberName] string member = "")
{
InternalCalls.Debug_LogWarning(message ?? string.Empty);
InternalCalls.Debug_LogWarning(message ?? string.Empty, file ?? string.Empty, line, member ?? string.Empty);
}
public static void LogError(string message)
public static void LogError(
string message,
[CallerFilePath] string file = "",
[CallerLineNumber] int line = 0,
[CallerMemberName] string member = "")
{
InternalCalls.Debug_LogError(message ?? string.Empty);
InternalCalls.Debug_LogError(message ?? string.Empty, file ?? string.Empty, line, member ?? string.Empty);
}
}
}

View File

@@ -6,13 +6,13 @@ namespace XCEngine
internal static class InternalCalls
{
[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern void Debug_Log(string message);
internal static extern void Debug_Log(string message, string file, int line, string member);
[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern void Debug_LogWarning(string message);
internal static extern void Debug_LogWarning(string message, string file, int line, string member);
[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern void Debug_LogError(string message);
internal static extern void Debug_LogError(string message, string file, int line, string member);
[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern float Time_GetDeltaTime();