Write a utility.log to the logs dir when the utility crashes

This commit is contained in:
Paul Chote
2011-03-30 20:52:54 +13:00
parent 5d762b1f9c
commit 3dda9ee607
2 changed files with 24 additions and 10 deletions

View File

@@ -42,7 +42,7 @@ namespace OpenRA
{ {
Process p = new Process(); Process p = new Process();
p.StartInfo.FileName = Utility; p.StartInfo.FileName = Utility;
p.StartInfo.Arguments = args; p.StartInfo.Arguments = "{0} --SupportDir \"{1}\"".F(args, Game.SupportDir);
p.StartInfo.UseShellExecute = false; p.StartInfo.UseShellExecute = false;
p.StartInfo.CreateNoWindow = true; p.StartInfo.CreateNoWindow = true;
p.StartInfo.RedirectStandardOutput = true; p.StartInfo.RedirectStandardOutput = true;
@@ -58,7 +58,7 @@ namespace OpenRA
{ {
Process p = new Process(); Process p = new Process();
p.StartInfo.FileName = Utility; p.StartInfo.FileName = Utility;
p.StartInfo.Arguments = args; p.StartInfo.Arguments = "{0} --SupportDir \"{1}\"".F(args, Game.SupportDir);
p.StartInfo.UseShellExecute = false; p.StartInfo.UseShellExecute = false;
p.StartInfo.CreateNoWindow = true; p.StartInfo.CreateNoWindow = true;
p.StartInfo.RedirectStandardOutput = true; p.StartInfo.RedirectStandardOutput = true;

View File

@@ -31,7 +31,7 @@ namespace OpenRA.Utility
ps.AddAccessRule(new PipeAccessRule("EVERYONE", (PipeAccessRights)2032031, AccessControlType.Allow)); ps.AddAccessRule(new PipeAccessRule("EVERYONE", (PipeAccessRights)2032031, AccessControlType.Allow));
return ps; return ps;
} }
static void Main(string[] args) static void Main(string[] args)
{ {
var actions = new Dictionary<string, Action<string[]>>() var actions = new Dictionary<string, Action<string[]>>()
@@ -62,13 +62,27 @@ namespace OpenRA.Utility
pipe.WaitForConnection(); pipe.WaitForConnection();
Console.SetOut(new StreamWriter(pipe) { AutoFlush = true }); Console.SetOut(new StreamWriter(pipe) { AutoFlush = true });
} }
i = Array.IndexOf(args, "--SupportDir");
if (args.Length > 1 && i >= 0)
var action = WithDefault( null, () => actions[args[0]]); {
if (action == null) Log.LogPath = args[i+1] + Path.DirectorySeparatorChar + "Logs" + Path.DirectorySeparatorChar;
PrintUsage(); Console.WriteLine("LogPath: {0}", Log.LogPath);
else }
action(args); try
{
throw new InvalidOperationException("foo");
var action = WithDefault( null, () => actions[args[0]]);
if (action == null)
PrintUsage();
else
action(args);
}
catch( Exception e )
{
Log.AddChannel("utility", "utility.log");
Log.Write("utility", "{0}", e.ToString());
throw;
}
if (piping) if (piping)
Console.Out.Close(); Console.Out.Close();