Skip to content

Commit 6e9300e

Browse files
committed
ReadirectInternalLogs: Fix Unity output log not working
1 parent 120fe7d commit 6e9300e

5 files changed

Lines changed: 8 additions & 9 deletions

File tree

src/RedirectInternalLogs/InternalUnityLogger.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public static class InternalUnityLogger
2424
{
2525
public static event EventHandler<UnityLogEventArgs> OnUnityInternalLog;
2626

27-
internal static void OnUnityLog(InternalLogLevel logLevel, string message, IntPtr parts)
27+
internal static void OnUnityLog(InternalLogLevel logLevel, IntPtr message, IntPtr parts)
2828
{
2929
try
3030
{

src/RedirectInternalLogs/Platforms/X64Patcher.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ protected override void Apply(IntPtr from)
3333
det.Apply();
3434
}
3535

36-
private static void OnUnityLog(ulong type, string message, IntPtr args)
36+
private static void OnUnityLog(ulong type, IntPtr message, IntPtr args)
3737
{
3838
InternalUnityLogger.OnUnityLog((InternalLogLevel) type, message, args);
3939
original(type, message, args);
4040
}
4141

4242
[UnmanagedFunctionPointer(CallingConvention.FastCall)]
43-
private delegate void PrintFDelegate(ulong type, [MarshalAs(UnmanagedType.LPStr)] string pattern, IntPtr parts);
43+
private delegate void PrintFDelegate(ulong type, IntPtr pattern, IntPtr parts);
4444
}
4545
}

src/RedirectInternalLogs/Platforms/X86Patcher.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ protected virtual void Apply(IntPtr from)
5353
det.Apply();
5454
}
5555

56-
private static void OnLogHook(uint type, string pattern, IntPtr args)
56+
private static void OnLogHook(uint type, IntPtr pattern, IntPtr args)
5757
{
5858
InternalUnityLogger.OnUnityLog((InternalLogLevel) type, pattern, args);
5959
original(type, pattern, args);
@@ -82,6 +82,6 @@ private unsafe IntPtr FindMatch(IntPtr start, int maxSize)
8282
}
8383

8484
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
85-
private delegate void PrintFDelegate(uint type, [MarshalAs(UnmanagedType.LPStr)] string pattern, IntPtr parts);
85+
private delegate void PrintFDelegate(uint type, IntPtr pattern, IntPtr parts);
8686
}
8787
}

src/RedirectInternalLogs/RedirectInternalLogsPatcher.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ private static void InitializeFileLog()
8282

8383
private static void InternalUnityLoggerOnOnUnityInternalLog(object sender, UnityLogEventArgs e)
8484
{
85-
writer.Write($"[{e.LogLevel}] {e.Message}");
85+
writer.WriteLine($"[{e.LogLevel}] {e.Message.Trim()}");
8686
}
8787
}
8888
}

src/RedirectInternalLogs/Util/LibcHelper.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ internal static class LibcHelper
1010
{
1111
[DynDllImport("libc", "vsprintf_s")] private static readonly VsPrintFsDelegate VsPrintF = null;
1212

13-
public static string Format(string format, IntPtr args, int buffer = 8192)
13+
public static string Format(IntPtr format, IntPtr args, int buffer = 8192)
1414
{
1515
var sb = new StringBuilder(buffer);
1616
VsPrintF(sb, sb.Capacity, format, args);
@@ -31,7 +31,6 @@ public static void Init()
3131
}
3232

3333
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
34-
private delegate int VsPrintFsDelegate([MarshalAs(UnmanagedType.LPStr)] StringBuilder dest, int size,
35-
[MarshalAs(UnmanagedType.LPStr)] string fmt, IntPtr vaList);
34+
private delegate int VsPrintFsDelegate([MarshalAs(UnmanagedType.LPStr)] StringBuilder dest, int size, IntPtr fmt, IntPtr vaList);
3635
}
3736
}

0 commit comments

Comments
 (0)