Rain World Modding Wiki

Here we will create a basic global exception logger for Rain World. With this, whenever you run Rain World, two text files may appear in the root Rain World Directory. "consoleLog.txt" will show any standard debug console output the game writes. "exceptionLog.txt" will show errors and stack traces if the game crashes or freezes.

In the RainWorld class, add the following new methods, making sure to add "using System.IO;" at the top:

private void Awake()
{
	if (File.Exists("exceptionLog.txt"))
		File.Delete("exceptionLog.txt");
	if (File.Exists("consoleLog.txt"))
		File.Delete("consoleLog.txt");
	Application.RegisterLogCallback(new Application.LogCallback(this.HandleLog));
}

public void HandleLog(string logString, string stackTrace, LogType type)
{
	if (type == LogType.Error || type == LogType.Exception)
	{
		File.AppendAllText("exceptionLog.txt", logString + Environment.NewLine);
		File.AppendAllText("exceptionLog.txt", stackTrace + Environment.NewLine);
		return;
	}
	File.AppendAllText("consoleLog.txt", logString + Environment.NewLine);
}