Fix issues with preloader error log writing

Rebase of 849f056
This commit is contained in:
Bepis committed 2020-11-05 23:27:58 +11:00
1 parent 0b7db81420
commit 037198a3a1
1 file changed
+15 -9
+15 -9
View File
@@ -124,26 +124,32 @@ namespace BepInEx.Preloader.Unity
Log.LogFatal("Could not run preloader!");
Log.LogFatal(ex);
PreloaderLog?.Dispose();
if (!ConsoleManager.ConsoleActive)
{
//if we've already attached the console, then the log will already be written to the console
AllocateConsole();
Console.Write(PreloaderLog);
}
PreloaderLog = null;
}
finally
catch { }
string log = string.Empty;
try
{
File.WriteAllText(
Path.Combine(Paths.GameRootPath, $"preloader_{DateTime.Now:yyyyMMdd_HHmmss_fff}.log"),
PreloaderLog + "\r\n" + ex);
// We could use platform-dependent newlines, however the developers use Windows so this will be easier to read :)
log = string.Join("\r\n", PreloaderConsoleListener.LogEvents.Select(x => x.ToString()).ToArray());
log += "\r\n";
PreloaderLog?.Dispose();
PreloaderLog = null;
}
catch { }
File.WriteAllText(
Path.Combine(Paths.GameRootPath, $"preloader_{DateTime.Now:yyyyMMdd_HHmmss_fff}.log"),
log + ex);
}
}
@@ -165,7 +171,7 @@ namespace BepInEx.Preloader.Unity
var entryType = assembly.MainModule.Types.FirstOrDefault(x => x.Name == entrypointType);
if (entryType == null)
throw new Exception("The entrypoint type is invalid! Please check your config.ini");
throw new Exception("The entrypoint type is invalid! Please check your config/BepInEx.cfg file");
string chainloaderAssemblyPath = Path.Combine(Paths.BepInExAssemblyDirectory, "BepInEx.Unity.dll");