added OpenRA, OS and .NET/Mono runtime version to exception.log

This commit is contained in:
Matthias Mailänder
2013-10-15 17:56:31 +02:00
parent 8c8df3bda9
commit 70ba7fe5f6
2 changed files with 23 additions and 1 deletions

View File

@@ -11,6 +11,7 @@
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Reflection;
using OpenRA.FileFormats; using OpenRA.FileFormats;
namespace OpenRA namespace OpenRA
@@ -45,6 +46,22 @@ namespace OpenRA
return PlatformType.Unknown; return PlatformType.Unknown;
} }
public static string RuntimeVersion
{
get
{
var mono = Type.GetType("Mono.Runtime");
if (mono == null)
return ".NET CLR {0}".F(Environment.Version);
var version = mono.GetMethod("GetDisplayName", BindingFlags.NonPublic | BindingFlags.Static);
if (version == null)
return "Mono (unknown version) CLR {0}".F(Environment.Version);
return "Mono {0} CLR {1}".F(version.Invoke(null, null), Environment.Version);
}
}
public static string SupportDir public static string SupportDir
{ {
get get

View File

@@ -46,6 +46,10 @@ namespace OpenRA
static void FatalError(Exception e) static void FatalError(Exception e)
{ {
Log.AddChannel("exception", "exception.log"); Log.AddChannel("exception", "exception.log");
var mod = Game.CurrentMods.First().Value;
Log.Write("exception", "{0} Mod at Version {1}", mod.Title, mod.Version);
Log.Write("exception", "Operating System: {0} ({1})", Platform.CurrentPlatform, Environment.OSVersion);
Log.Write("exception", "Runtime Version: {0}", Platform.RuntimeVersion);
var rpt = BuildExceptionReport(e).ToString(); var rpt = BuildExceptionReport(e).ToString();
Log.Write("exception", "{0}", rpt); Log.Write("exception", "{0}", rpt);
Console.Error.WriteLine(rpt); Console.Error.WriteLine(rpt);
@@ -69,7 +73,8 @@ namespace OpenRA
static StringBuilder BuildExceptionReport(Exception e, StringBuilder sb, int d) static StringBuilder BuildExceptionReport(Exception e, StringBuilder sb, int d)
{ {
if (e == null) return sb; if (e == null)
return sb;
sb.AppendFormat("Exception of type `{0}`: {1}", e.GetType().FullName, e.Message); sb.AppendFormat("Exception of type `{0}`: {1}", e.GetType().FullName, e.Message);