Kill broken log uploading
This commit is contained in:
@@ -19,10 +19,8 @@ namespace OpenRA
|
|||||||
{
|
{
|
||||||
public struct ChannelInfo
|
public struct ChannelInfo
|
||||||
{
|
{
|
||||||
public bool Upload;
|
|
||||||
public string Filename;
|
public string Filename;
|
||||||
public StreamWriter Writer;
|
public StreamWriter Writer;
|
||||||
public bool Diff;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Log
|
public static class Log
|
||||||
@@ -41,7 +39,7 @@ namespace OpenRA
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void AddChannel(string channelName, string filename, bool upload, bool diff)
|
public static void AddChannel(string channelName, string filename)
|
||||||
{
|
{
|
||||||
if (channels.ContainsKey(channelName)) return;
|
if (channels.ContainsKey(channelName)) return;
|
||||||
|
|
||||||
@@ -52,7 +50,7 @@ namespace OpenRA
|
|||||||
{
|
{
|
||||||
StreamWriter writer = File.CreateText(LogPathPrefix + filename);
|
StreamWriter writer = File.CreateText(LogPathPrefix + 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() { Filename = filename, Writer = writer });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
catch (IOException) { filename = f + ".{0}".F(++i); }
|
catch (IOException) { filename = f + ".{0}".F(++i); }
|
||||||
@@ -60,7 +58,7 @@ namespace OpenRA
|
|||||||
//if no logs exist, just make it
|
//if no logs exist, just make it
|
||||||
StreamWriter w = File.CreateText(LogPathPrefix + filename);
|
StreamWriter w = File.CreateText(LogPathPrefix + filename);
|
||||||
w.AutoFlush = true;
|
w.AutoFlush = true;
|
||||||
channels.Add(channelName, new ChannelInfo() { Upload = upload, Filename = filename, Writer = w, Diff = diff });
|
channels.Add(channelName, new ChannelInfo() { Filename = filename, Writer = w });
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,37 +70,5 @@ namespace OpenRA
|
|||||||
|
|
||||||
info.Writer.WriteLine(format, args);
|
info.Writer.WriteLine(format, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Upload(int gameId)
|
|
||||||
{
|
|
||||||
foreach (var kvp in channels.Where(x => x.Value.Upload))
|
|
||||||
{
|
|
||||||
kvp.Value.Writer.Close();
|
|
||||||
var logfile = File.OpenRead(Log.LogPathPrefix + kvp.Value.Filename);
|
|
||||||
byte[] fileContents = logfile.ReadAllBytes();
|
|
||||||
var ms = new MemoryStream();
|
|
||||||
|
|
||||||
using (var gzip = new GZipStream(ms, CompressionMode.Compress, true))
|
|
||||||
gzip.Write(fileContents, 0, fileContents.Length);
|
|
||||||
|
|
||||||
ms.Position = 0;
|
|
||||||
byte[] buffer = ms.ReadAllBytes();
|
|
||||||
|
|
||||||
WebRequest request = WebRequest.Create("http://open-ra.org/logs/upload.php");
|
|
||||||
request.ContentType = "application/x-gzip";
|
|
||||||
request.ContentLength = buffer.Length;
|
|
||||||
request.Method = "POST";
|
|
||||||
request.Headers.Add("Game-ID", gameId.ToString());
|
|
||||||
request.Headers.Add("Channel", kvp.Key);
|
|
||||||
// request.Headers.Add("Diff", kvp.Value.Diff ? "1" : "0");
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using (var requestStream = request.GetRequestStream())
|
|
||||||
requestStream.Write(buffer, 0, buffer.Length);
|
|
||||||
}
|
|
||||||
catch (Exception){}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -497,9 +497,9 @@ namespace OpenRA
|
|||||||
Settings = new UserSettings(settings);
|
Settings = new UserSettings(settings);
|
||||||
|
|
||||||
Log.LogPath = SupportDir + "Logs" + Path.DirectorySeparatorChar;
|
Log.LogPath = SupportDir + "Logs" + Path.DirectorySeparatorChar;
|
||||||
Log.AddChannel("perf", "perf.log", false, false);
|
Log.AddChannel("perf", "perf.log");
|
||||||
Log.AddChannel("debug", "debug.log", false, false);
|
Log.AddChannel("debug", "debug.log");
|
||||||
Log.AddChannel("sync", "syncreport.log", true, true);
|
Log.AddChannel("sync", "syncreport.log");
|
||||||
|
|
||||||
LobbyInfo.GlobalSettings.Mods = Settings.InitialMods;
|
LobbyInfo.GlobalSettings.Mods = Settings.InitialMods;
|
||||||
Manifest = new Manifest(LobbyInfo.GlobalSettings.Mods);
|
Manifest = new Manifest(LobbyInfo.GlobalSettings.Mods);
|
||||||
@@ -584,28 +584,6 @@ namespace OpenRA
|
|||||||
get {return baseSupportDir;}
|
get {return baseSupportDir;}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
internal static int GetGameId()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
string s = File.ReadAllText(SupportDir + "currentgameid");
|
|
||||||
return int.Parse(s);
|
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static void SetGameId(int id)
|
|
||||||
{
|
|
||||||
var file = File.CreateText(SupportDir + "currentgameid");
|
|
||||||
file.Write(id);
|
|
||||||
file.Flush();
|
|
||||||
file.Close();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void InitializeEngineWithMods(string[] mods)
|
public static void InitializeEngineWithMods(string[] mods)
|
||||||
{
|
{
|
||||||
AppDomain.CurrentDomain.AssemblyResolve += FileSystem.ResolveAssembly;
|
AppDomain.CurrentDomain.AssemblyResolve += FileSystem.ResolveAssembly;
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ namespace OpenRA.GameRules
|
|||||||
public bool PerfDebug = false;
|
public bool PerfDebug = false;
|
||||||
public bool RecordSyncReports = true;
|
public bool RecordSyncReports = true;
|
||||||
public bool ShowGameTimer = true;
|
public bool ShowGameTimer = true;
|
||||||
public bool DeveloperMode = false;
|
|
||||||
public bool UnitDebug = false;
|
public bool UnitDebug = false;
|
||||||
|
|
||||||
// Window settings
|
// Window settings
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ namespace OpenRA.Server
|
|||||||
public static void ServerMain(bool internetServer, string masterServerUrl, string name, int port, int extport,
|
public static void ServerMain(bool internetServer, string masterServerUrl, string name, int port, int extport,
|
||||||
string[] mods, string map, bool cheats)
|
string[] mods, string map, bool cheats)
|
||||||
{
|
{
|
||||||
Log.AddChannel("server", "server.log", false, false);
|
Log.AddChannel("server", "server.log");
|
||||||
|
|
||||||
isInitialPing = true;
|
isInitialPing = true;
|
||||||
Server.masterServerUrl = masterServerUrl;
|
Server.masterServerUrl = masterServerUrl;
|
||||||
@@ -479,14 +479,8 @@ namespace OpenRA.Server
|
|||||||
if (isInitialPing)
|
if (isInitialPing)
|
||||||
{
|
{
|
||||||
isInitialPing = false;
|
isInitialPing = false;
|
||||||
|
|
||||||
var s = Encoding.UTF8.GetString(result);
|
|
||||||
int gameId;
|
|
||||||
if (int.TryParse(s.Trim(), out gameId))
|
|
||||||
Game.SetGameId(gameId);
|
|
||||||
|
|
||||||
lock (masterServerMessages)
|
lock (masterServerMessages)
|
||||||
masterServerMessages.Enqueue("Master server communication established. Game ID = {0}".F(gameId));
|
masterServerMessages.Enqueue("Master server communication established.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,10 +36,8 @@ namespace OpenRA
|
|||||||
}
|
}
|
||||||
catch( Exception e )
|
catch( Exception e )
|
||||||
{
|
{
|
||||||
Log.AddChannel("exception", "openra.exception.txt", true, false);
|
Log.AddChannel("exception", "exception.log");
|
||||||
Log.Write("exception", "{0}", e.ToString());
|
Log.Write("exception", "{0}", e.ToString());
|
||||||
if (!Game.Settings.DeveloperMode || ( Game.Settings.DeveloperMode && Game.GetGameId() != 0) )
|
|
||||||
Log.Upload(Game.GetGameId());
|
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -121,7 +121,6 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
|
|
||||||
r.CloseWindow();
|
r.CloseWindow();
|
||||||
Game.JoinServer(currentServer.Address.Split(':')[0], int.Parse(currentServer.Address.Split(':')[1]));
|
Game.JoinServer(currentServer.Address.Split(':')[0], int.Parse(currentServer.Address.Split(':')[1]));
|
||||||
Game.SetGameId(currentServer.Id);
|
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user