From 36a660385c060e02a0f973056a3f25d6054c50a8 Mon Sep 17 00:00:00 2001 From: Pavlos Touboulidis Date: Wed, 23 Apr 2014 13:22:14 +0300 Subject: [PATCH] Fix OpenRA.Lint throwing because "perf" log channel does not exist Slightly modified the Log class to allow dummy channels that don't write anywhere, then use it on Lint because map loading writes to the "perf" channel. --- OpenRA.Game/Support/Log.cs | 9 +++++++++ OpenRA.Lint/YamlChecker.cs | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/OpenRA.Game/Support/Log.cs b/OpenRA.Game/Support/Log.cs index 19c62e07eb..b837815a96 100755 --- a/OpenRA.Game/Support/Log.cs +++ b/OpenRA.Game/Support/Log.cs @@ -46,6 +46,12 @@ namespace OpenRA { if (Channels.ContainsKey(channelName)) return; + if (string.IsNullOrEmpty(baseFilename)) + { + Channels.Add(channelName, new ChannelInfo()); + return; + } + foreach (var filename in FilenamesForChannel(channelName, baseFilename)) try { @@ -70,6 +76,9 @@ namespace OpenRA if (!Channels.TryGetValue(channel, out info)) throw new Exception("Tried logging to non-existant channel " + channel); + if (info.Writer == null) + return; + info.Writer.WriteLine(format, args); } } diff --git a/OpenRA.Lint/YamlChecker.cs b/OpenRA.Lint/YamlChecker.cs index 61ded227c4..979c09176e 100644 --- a/OpenRA.Lint/YamlChecker.cs +++ b/OpenRA.Lint/YamlChecker.cs @@ -6,6 +6,9 @@ * as published by the Free Software Foundation. For more information, * see COPYING. */ +using System.IO; + + #endregion using System; @@ -41,6 +44,8 @@ namespace OpenRA.Lint try { + Log.AddChannel("perf", null); + var options = args.Where(a => a.StartsWith("-")); var mod = args.Where(a => !options.Contains(a)).First(); var map = args.Where(a => !options.Contains(a)).Skip(1).FirstOrDefault();