better instance logging support
This commit is contained in:
@@ -55,19 +55,23 @@ namespace OpenRA
|
|||||||
{
|
{
|
||||||
if (channels.ContainsKey(channelName)) return;
|
if (channels.ContainsKey(channelName)) return;
|
||||||
|
|
||||||
/* HACK: avoid sharing violations if running multiple instances */
|
var i = 0;
|
||||||
StreamWriter writer = null;
|
var f = filename;
|
||||||
while (writer == null)
|
while (File.Exists(LogPathPrefix + filename))
|
||||||
{
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
writer = File.CreateText(LogPathPrefix + filename);
|
StreamWriter writer = File.CreateText(LogPathPrefix + filename);
|
||||||
}
|
|
||||||
catch(IOException){ filename = new Random().Next().ToString() + filename; }
|
|
||||||
}
|
|
||||||
|
|
||||||
writer.AutoFlush = true;
|
writer.AutoFlush = true;
|
||||||
channels.Add(channelName, new ChannelInfo() { Upload = upload, Filename = filename, Writer = writer, Diff = diff });
|
channels.Add(channelName, new ChannelInfo() { Upload = upload, Filename = filename, Writer = writer, Diff = diff });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
catch (IOException) { filename = f + ".{0}".F(++i); }
|
||||||
|
|
||||||
|
//if no logs exist, just make it
|
||||||
|
StreamWriter w = File.CreateText(LogPathPrefix + filename);
|
||||||
|
w.AutoFlush = true;
|
||||||
|
channels.Add(channelName, new ChannelInfo() { Upload = upload, Filename = filename, Writer = w, Diff = diff });
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Write(string channel, string format, params object[] args)
|
public static void Write(string channel, string format, params object[] args)
|
||||||
|
|||||||
@@ -626,7 +626,11 @@ namespace OpenRA
|
|||||||
|
|
||||||
public static void Exit() { quit = true; }
|
public static void Exit() { quit = true; }
|
||||||
|
|
||||||
public static void Debug(string s) { Chrome.chatWidget.AddLine(Color.White, "Debug", s); }
|
public static void Debug(string s)
|
||||||
|
{
|
||||||
|
if (Chrome.chatWidget != null)
|
||||||
|
Chrome.chatWidget.AddLine(Color.White, "Debug", s);
|
||||||
|
}
|
||||||
|
|
||||||
public static void Disconnect()
|
public static void Disconnect()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user