Deprecate string format log shorthand.

This commit is contained in:
Matthias Mailänder
2023-05-04 17:44:46 +02:00
committed by abcdefg30
parent e251126dd4
commit 1c2ce0dcc0
27 changed files with 100 additions and 84 deletions

View File

@@ -187,8 +187,10 @@ namespace OpenRA
} }
catch (Exception e) catch (Exception e)
{ {
Log.Write("debug", "Failed to decrypt string with exception: {0}", e); Log.Write("debug", "Failed to decrypt string with exception:");
Console.WriteLine("String decryption failed: {0}", e); Log.Write("debug", e);
Console.WriteLine("String decryption failed:");
Console.WriteLine(e);
return null; return null;
} }
} }
@@ -211,8 +213,10 @@ namespace OpenRA
} }
catch (Exception e) catch (Exception e)
{ {
Log.Write("debug", "Failed to sign string with exception: {0}", e); Log.Write("debug", "Failed to sign string with exception");
Console.WriteLine("String signing failed: {0}", e); Log.Write("debug", e);
Console.WriteLine("String signing failed:");
Console.WriteLine(e);
return null; return null;
} }
} }
@@ -235,8 +239,10 @@ namespace OpenRA
} }
catch (Exception e) catch (Exception e)
{ {
Log.Write("debug", "Failed to verify signature with exception: {0}", e); Log.Write("debug", "Failed to verify signature with exception:");
Console.WriteLine("Signature validation failed: {0}", e); Log.Write("debug", e);
Console.WriteLine("Signature validation failed:");
Console.WriteLine(e);
return false; return false;
} }
} }

View File

@@ -81,8 +81,8 @@ namespace OpenRA
} }
catch (Exception e) catch (Exception e)
{ {
Log.Write("debug", "Failed to parse mod metadata file '{0}'", path); Log.Write("debug", $"Failed to parse mod metadata file '{path}'");
Log.Write("debug", e.ToString()); Log.Write("debug", e);
} }
} }
} }
@@ -174,7 +174,7 @@ namespace OpenRA
catch (Exception e) catch (Exception e)
{ {
Log.Write("debug", "Failed to register current mod metadata"); Log.Write("debug", "Failed to register current mod metadata");
Log.Write("debug", e.ToString()); Log.Write("debug", e);
} }
} }
} }
@@ -213,8 +213,8 @@ namespace OpenRA
} }
catch (Exception e) catch (Exception e)
{ {
Log.Write("debug", "Failed to parse mod metadata file '{0}'", path); Log.Write("debug", $"Failed to parse mod metadata file '{path}'");
Log.Write("debug", e.ToString()); Log.Write("debug", e);
} }
// Remove from the ingame mod switcher // Remove from the ingame mod switcher
@@ -225,12 +225,12 @@ namespace OpenRA
try try
{ {
File.Delete(path); File.Delete(path);
Log.Write("debug", "Removed invalid mod metadata file '{0}'", path); Log.Write("debug", $"Removed invalid mod metadata file '{path}'");
} }
catch (Exception e) catch (Exception e)
{ {
Log.Write("debug", "Failed to remove mod metadata file '{0}'", path); Log.Write("debug", $"Failed to remove mod metadata file '{path}'");
Log.Write("debug", e.ToString()); Log.Write("debug", e);
} }
} }
} }
@@ -251,8 +251,8 @@ namespace OpenRA
} }
catch (Exception e) catch (Exception e)
{ {
Log.Write("debug", "Failed to remove mod metadata file '{0}'", path); Log.Write("debug", $"Failed to remove mod metadata file '{path}'");
Log.Write("debug", e.ToString()); Log.Write("debug", e);
} }
} }
} }

View File

@@ -263,13 +263,13 @@ namespace OpenRA.Graphics
if (!collections.TryGetValue(collectionName, out var collection)) if (!collections.TryGetValue(collectionName, out var collection))
{ {
Log.Write("debug", "Could not find collection '{0}'", collectionName); Log.Write("debug", $"Could not find collection '{collectionName}'");
return new Size(0, 0); return new Size(0, 0);
} }
if (collection.PanelRegion == null || collection.PanelRegion.Length != 8) if (collection.PanelRegion == null || collection.PanelRegion.Length != 8)
{ {
Log.Write("debug", "Collection '{0}' does not define a valid PanelRegion", collectionName); Log.Write("debug", $"Collection '{collectionName}' does not define a valid PanelRegion");
return new Size(0, 0); return new Size(0, 0);
} }

View File

@@ -66,8 +66,10 @@ namespace OpenRA
} }
catch (Exception e) catch (Exception e)
{ {
Console.WriteLine("Failed to load keys: {0}", e); Console.WriteLine("Failed to load keys:");
Log.Write("debug", "Failed to load player keypair from `{0}` with exception: {1}", filePath, e); Console.WriteLine(e);
Log.Write("debug", $"Failed to load player keypair from `{filePath}` with exception:");
Log.Write("debug", e);
} }
} }
@@ -91,7 +93,7 @@ namespace OpenRA
innerData = FieldLoader.Load<PlayerProfile>(yaml.Value); innerData = FieldLoader.Load<PlayerProfile>(yaml.Value);
if (innerData.KeyRevoked) if (innerData.KeyRevoked)
{ {
Log.Write("debug", "Revoking key with fingerprint {0}", Fingerprint); Log.Write("debug", $"Revoking key with fingerprint {Fingerprint}");
DeleteKeypair(); DeleteKeypair();
} }
else else
@@ -102,7 +104,8 @@ namespace OpenRA
} }
catch (Exception e) catch (Exception e)
{ {
Log.Write("debug", "Failed to parse player data result with exception: {0}", e); Log.Write("debug", "Failed to parse player data result with exception:");
Log.Write("debug", e);
innerState = LinkState.ConnectionFailed; innerState = LinkState.ConnectionFailed;
} }
finally finally
@@ -136,8 +139,10 @@ namespace OpenRA
} }
catch (Exception e) catch (Exception e)
{ {
Log.Write("debug", "Failed to generate keypair with exception: {1}", e); Log.Write("debug", "Failed to generate keypair with exception:");
Console.WriteLine("Key generation failed: {0}", e); Log.Write("debug", e);
Console.WriteLine("Key generation failed:");
Console.WriteLine(e);
innerState = LinkState.Uninitialized; innerState = LinkState.Uninitialized;
} }
@@ -152,8 +157,10 @@ namespace OpenRA
} }
catch (Exception e) catch (Exception e)
{ {
Log.Write("debug", "Failed to delete keypair with exception: {1}", e); Log.Write("debug", "Failed to delete keypair with exception:");
Console.WriteLine("Key deletion failed: {0}", e); Log.Write("debug", e);
Console.WriteLine("Key deletion failed:");
Console.WriteLine(e);
} }
innerState = LinkState.Uninitialized; innerState = LinkState.Uninitialized;

View File

@@ -441,7 +441,8 @@ namespace OpenRA
} }
catch (Exception e) catch (Exception e)
{ {
Log.Write("debug", "Failed to load rules for {0} with error {1}", Title, e); Log.Write("debug", $"Failed to load rules for {Title} with error");
Log.Write("debug", e);
InvalidCustomRules = true; InvalidCustomRules = true;
InvalidCustomRulesException = e; InvalidCustomRulesException = e;
Rules = Ruleset.LoadDefaultsForTileSet(modData, Tileset); Rules = Ruleset.LoadDefaultsForTileSet(modData, Tileset);
@@ -1204,7 +1205,7 @@ namespace OpenRA
// This shouldn't happen. But if it does, return the original value and hope the caller doesn't explode. // This shouldn't happen. But if it does, return the original value and hope the caller doesn't explode.
if (unProjected.Count == 0) if (unProjected.Count == 0)
{ {
Log.Write("debug", "Failed to clamp map cell {0} to map bounds", uv); Log.Write("debug", $"Failed to clamp map cell {uv} to map bounds");
return uv; return uv;
} }
} }
@@ -1276,7 +1277,7 @@ namespace OpenRA
// This shouldn't happen. But if it does, return the original value and hope the caller doesn't explode. // This shouldn't happen. But if it does, return the original value and hope the caller doesn't explode.
if (unProjected.Count == 0) if (unProjected.Count == 0)
{ {
Log.Write("debug", "Failed to find closest edge for map cell {0}", uv); Log.Write("debug", $"Failed to find closest edge for map cell {uv}");
return uv; return uv;
} }
} }

View File

@@ -158,10 +158,12 @@ namespace OpenRA
catch (Exception e) catch (Exception e)
{ {
mapPackage?.Dispose(); mapPackage?.Dispose();
Console.WriteLine("Failed to load map: {0}", map); Console.WriteLine($"Failed to load map: {map}");
Console.WriteLine("Details: {0}", e); Console.WriteLine("Details:");
Log.Write("debug", "Failed to load map: {0}", map); Console.WriteLine(e);
Log.Write("debug", "Details: {0}", e); Log.Write("debug", $"Failed to load map: {map}");
Log.Write("debug", "Details:");
Log.Write("debug", e);
} }
} }
@@ -253,8 +255,9 @@ namespace OpenRA
} }
catch (Exception e) catch (Exception e)
{ {
Log.Write("debug", "Remote map query failed with error: {0}", e); Log.Write("debug", "Remote map query failed with error:");
Log.Write("debug", "URL was: {0}", url); Log.Write("debug", e);
Log.Write("debug", $"URL was: {url}");
foreach (var uid in batchUids) foreach (var uid in batchUids)
{ {
@@ -315,7 +318,8 @@ namespace OpenRA
} }
catch (Exception e) catch (Exception e)
{ {
Log.Write("debug", "Failed to load minimap with exception: {0}", e); Log.Write("debug", "Failed to load minimap with exception:");
Log.Write("debug", e);
} }
}); });
} }

View File

@@ -128,7 +128,8 @@ namespace OpenRA.Network
} }
catch (Exception e) catch (Exception e)
{ {
Log.Write("geoip", "DatabaseReader failed: {0}", e); Log.Write("geoip", "DatabaseReader failed:");
Log.Write("geoip", e);
} }
} }
@@ -142,7 +143,8 @@ namespace OpenRA.Network
} }
catch (Exception e) catch (Exception e)
{ {
Log.Write("geoip", "LookupCountry failed: {0}", e); Log.Write("geoip", "LookupCountry failed:");
Log.Write("geoip", e);
} }
} }

View File

@@ -49,8 +49,8 @@ namespace OpenRA.Network
// Only interact with one at a time. Some support both UPnP and NAT-PMP. // Only interact with one at a time. Some support both UPnP and NAT-PMP.
natDevice = args.Device; natDevice = args.Device;
Log.Write("nat", "Device found: {0}", natDevice.DeviceEndpoint); Log.Write("nat", $"Device found: {natDevice.DeviceEndpoint}");
Log.Write("nat", "Type: {0}", natDevice.NatProtocol); Log.Write("nat", $"Type: {natDevice.NatProtocol}");
} }
finally finally
{ {

View File

@@ -209,7 +209,7 @@ namespace OpenRA
default: default:
{ {
Log.Write("debug", "Received unknown order with type {0}", type); Log.Write("debug", $"Received unknown order with type {type}");
return null; return null;
} }
} }
@@ -217,7 +217,7 @@ namespace OpenRA
catch (Exception e) catch (Exception e)
{ {
Log.Write("debug", "Caught exception while processing order"); Log.Write("debug", "Caught exception while processing order");
Log.Write("debug", e.ToString()); Log.Write("debug", e);
// HACK: this can hopefully go away in the future // HACK: this can hopefully go away in the future
TextNotificationsManager.Debug("Ignoring malformed order that would have crashed the game"); TextNotificationsManager.Debug("Ignoring malformed order that would have crashed the game");

View File

@@ -119,12 +119,12 @@ namespace OpenRA.Network
{ {
desyncFrameFound = true; desyncFrameFound = true;
var mod = Game.ModData.Manifest.Metadata; var mod = Game.ModData.Manifest.Metadata;
Log.Write("sync", "Player: {0} ({1} {2} {3})", Game.Settings.Player.Name, Platform.CurrentPlatform, Environment.OSVersion, Platform.RuntimeVersion); Log.Write("sync", $"Player: {Game.Settings.Player.Name} ({Platform.CurrentPlatform} {Environment.OSVersion} {Platform.RuntimeVersion})");
if (Game.IsHost) if (Game.IsHost)
Log.Write("sync", "Player is host."); Log.Write("sync", "Player is host.");
Log.Write("sync", "Game ID: {0} (Mod: {1} at Version {2})", orderManager.LobbyInfo.GlobalSettings.GameUid, mod.Title, mod.Version); Log.Write("sync", $"Game ID: {orderManager.LobbyInfo.GlobalSettings.GameUid} (Mod: {mod.Title} at Version {mod.Version})");
Log.Write("sync", "Sync for net frame {0} -------------", r.Frame); Log.Write("sync", $"Sync for net frame {r.Frame} -------------");
Log.Write("sync", "SharedRandom: {0} (#{1})", r.SyncedRandom, r.TotalCount); Log.Write("sync", $"SharedRandom: {r.SyncedRandom} (#{r.TotalCount})");
Log.Write("sync", "Synced Traits:"); Log.Write("sync", "Synced Traits:");
foreach (var a in r.Traits) foreach (var a in r.Traits)
{ {
@@ -139,7 +139,7 @@ namespace OpenRA.Network
Log.Write("sync", "Synced Effects:"); Log.Write("sync", "Synced Effects:");
foreach (var e in r.Effects) foreach (var e in r.Effects)
{ {
Log.Write("sync", "\t {0} ({1})", e.Name, e.Hash); Log.Write("sync", $"\t {e.Name} ({e.Hash})");
var nvp = e.NamesValues; var nvp = e.NamesValues;
for (var i = 0; i < nvp.Names.Length; i++) for (var i = 0; i < nvp.Names.Length; i++)
@@ -149,7 +149,7 @@ namespace OpenRA.Network
Log.Write("sync", "Orders Issued:"); Log.Write("sync", "Orders Issued:");
foreach (var o in r.Orders) foreach (var o in r.Orders)
Log.Write("sync", "\t {0}", o.ToString()); Log.Write("sync", $"\t {o}");
} }
} }

View File

@@ -216,7 +216,7 @@ namespace OpenRA
{ {
var logic = PlayerActor.TraitsImplementing<IBot>().FirstOrDefault(b => b.Info.Type == BotType); var logic = PlayerActor.TraitsImplementing<IBot>().FirstOrDefault(b => b.Info.Type == BotType);
if (logic == null) if (logic == null)
Log.Write("debug", "Invalid bot type: {0}", BotType); Log.Write("debug", $"Invalid bot type: {BotType}");
else else
logic.Activate(this); logic.Activate(this);
} }

View File

@@ -219,10 +219,10 @@ namespace OpenRA.Scripting
public void FatalError(string message) public void FatalError(string message)
{ {
var stacktrace = new StackTrace().ToString(); var stacktrace = new StackTrace().ToString();
Console.WriteLine("Fatal Lua Error: {0}", message); Console.WriteLine($"Fatal Lua Error: {message}");
Console.WriteLine(stacktrace); Console.WriteLine(stacktrace);
Log.Write("lua", "Fatal Lua Error: {0}", message); Log.Write("lua", $"Fatal Lua Error: {message}");
Log.Write("lua", stacktrace); Log.Write("lua", stacktrace);
FatalErrorOccurred = true; FatalErrorOccurred = true;

View File

@@ -39,7 +39,7 @@ namespace OpenRA.Server
void OnLintFailure(string message) void OnLintFailure(string message)
{ {
Log.Write("server", "Map {0} failed lint with error: {1}", map.Title, message); Log.Write("server", $"Map {map.Title} failed lint with error: {message}");
failed = true; failed = true;
} }
@@ -84,13 +84,13 @@ namespace OpenRA.Server
} }
catch (Exception e) catch (Exception e)
{ {
Log.Write("server", "Failed to load rules for `{0}` with error :{1}", map.Title, e.Message); Log.Write("server", $"Failed to load rules for `{map.Title}` with error: {e.Message}");
status = Session.MapStatus.Incompatible; status = Session.MapStatus.Incompatible;
} }
if (map.Players.Players.Count > MapPlayers.MaximumPlayerCount) if (map.Players.Players.Count > MapPlayers.MaximumPlayerCount)
{ {
Log.Write("server", "Failed to load `{0}`: Player count exceeds maximum ({1}/{2}).", map.Title, map.Players.Players.Count, MapPlayers.MaximumPlayerCount); Log.Write("server", $"Failed to load `{map.Title}`: Player count exceeds maximum ({map.Players.Players.Count}/{MapPlayers.MaximumPlayerCount}).");
status = Session.MapStatus.Incompatible; status = Session.MapStatus.Incompatible;
} }

View File

@@ -60,7 +60,7 @@ namespace OpenRA
{ {
if (!fileSystem.Exists(filename)) if (!fileSystem.Exists(filename))
{ {
Log.Write("sound", "LoadSound, file does not exist: {0}", filename); Log.Write("sound", $"LoadSound, file does not exist: {filename}");
return default; return default;
} }

View File

@@ -43,7 +43,7 @@ namespace OpenRA
Log.Write("exception", $"Date: {DateTime.UtcNow:u}"); Log.Write("exception", $"Date: {DateTime.UtcNow:u}");
Log.Write("exception", $"Operating System: {Platform.CurrentPlatform} ({Platform.CurrentArchitecture}, {Environment.OSVersion})"); Log.Write("exception", $"Operating System: {Platform.CurrentPlatform} ({Platform.CurrentArchitecture}, {Environment.OSVersion})");
Log.Write("exception", $"Runtime Version: {Platform.RuntimeVersion}", Platform.RuntimeVersion); Log.Write("exception", $"Runtime Version: {Platform.RuntimeVersion}");
Log.Write("exception", $"Installed Language: {CultureInfo.InstalledUICulture.TwoLetterISOLanguageName} (Installed) {CultureInfo.CurrentCulture.TwoLetterISOLanguageName} (Current) {CultureInfo.CurrentUICulture.TwoLetterISOLanguageName} (Current UI)"); Log.Write("exception", $"Installed Language: {CultureInfo.InstalledUICulture.TwoLetterISOLanguageName} (Installed) {CultureInfo.CurrentCulture.TwoLetterISOLanguageName} (Current) {CultureInfo.CurrentUICulture.TwoLetterISOLanguageName} (Current UI)");
var rpt = BuildExceptionReport(ex).ToString(); var rpt = BuildExceptionReport(ex).ToString();

View File

@@ -60,7 +60,7 @@ namespace OpenRA
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Write("client", "Failed to parse Launch.URI or Launch.Connect: {0}", ex.Message); Log.Write("client", $"Failed to parse Launch.URI or Launch.Connect: {ex.Message}");
return null; return null;
} }
} }

View File

@@ -176,11 +176,6 @@ namespace OpenRA
ChannelWriter.TryWrite(new ChannelData(channelName, $"{e.Message}{Environment.NewLine}{e.StackTrace}")); ChannelWriter.TryWrite(new ChannelData(channelName, $"{e.Message}{Environment.NewLine}{e.StackTrace}"));
} }
public static void Write(string channelName, string format, params object[] args)
{
ChannelWriter.TryWrite(new ChannelData(channelName, format.F(args)));
}
public static void Dispose() public static void Dispose()
{ {
CancellationToken.Cancel(); CancellationToken.Cancel();

View File

@@ -67,10 +67,10 @@ namespace OpenRA.Support
Log.Write("perf", GetHeader(Indentation, name)); Log.Write("perf", GetHeader(Indentation, name));
foreach (var child in children) foreach (var child in children)
child.Write(); child.Write();
Log.Write("perf", FormatString, ElapsedMs, GetFooter(Indentation)); Log.Write("perf", string.Format(FormatString, ElapsedMs, GetFooter(Indentation)));
} }
else if (ElapsedMs >= thresholdMs) else if (ElapsedMs >= thresholdMs)
Log.Write("perf", FormatString, ElapsedMs, Indentation + name); Log.Write("perf", string.Format(FormatString, ElapsedMs, Indentation + name));
} }
float ElapsedMs => 1000f * ticks / Stopwatch.Frequency; float ElapsedMs => 1000f * ticks / Stopwatch.Frequency;
@@ -79,9 +79,9 @@ namespace OpenRA.Support
{ {
var type = item.GetType(); var type = item.GetType();
var label = type == typeof(string) || type.IsGenericType ? item.ToString() : type.Name; var label = type == typeof(string) || type.IsGenericType ? item.ToString() : type.Name;
Log.Write("perf", FormatString, Log.Write("perf", string.Format(FormatString,
1000f * (endStopwatchTicks - startStopwatchTicks) / Stopwatch.Frequency, 1000f * (endStopwatchTicks - startStopwatchTicks) / Stopwatch.Frequency,
"[" + Game.LocalTick + "] " + name + ": " + label); "[" + Game.LocalTick + "] " + name + ": " + label));
} }
public static long LongTickThresholdInStopwatchTicks => (long)(Stopwatch.Frequency * Game.Settings.Debug.LongTickThresholdMs / 1000f); public static long LongTickThresholdInStopwatchTicks => (long)(Stopwatch.Frequency * Game.Settings.Debug.LongTickThresholdMs / 1000f);

View File

@@ -60,7 +60,7 @@ namespace OpenRA
{ {
Log.AddChannel("traitreport", "traitreport.log"); Log.AddChannel("traitreport", "traitreport.log");
foreach (var t in traits.OrderByDescending(t => t.Value.Queries).TakeWhile(t => t.Value.Queries > 0)) foreach (var t in traits.OrderByDescending(t => t.Value.Queries).TakeWhile(t => t.Value.Queries > 0))
Log.Write("traitreport", "{0}: {1}", t.Key.Name, t.Value.Queries); Log.Write("traitreport", $"{t.Key.Name}: {t.Value.Queries}");
} }
public void AddTrait(Actor actor, object val) public void AddTrait(Actor actor, object val)

View File

@@ -91,10 +91,10 @@ namespace OpenRA.Mods.Common.Scripting
{ {
var target = Target.FromActor(targetActor); var target = Target.FromActor(targetActor);
if (!target.IsValidFor(Self)) if (!target.IsValidFor(Self))
Log.Write("lua", "{1} is an invalid target for {0}!", Self, targetActor); Log.Write("lua", $"{targetActor} is an invalid target for {Self}!");
if (!targetActor.Info.HasTraitInfo<FrozenUnderFogInfo>() && !targetActor.CanBeViewedByPlayer(Self.Owner)) if (!targetActor.Info.HasTraitInfo<FrozenUnderFogInfo>() && !targetActor.CanBeViewedByPlayer(Self.Owner))
Log.Write("lua", "{1} is not revealed for player {0}!", Self.Owner, targetActor); Log.Write("lua", $"{targetActor} is not revealed for player {Self.Owner}!");
foreach (var attack in attackBases) foreach (var attack in attackBases)
attack.AttackTarget(target, AttackSource.Default, true, allowMove, forceAttack); attack.AttackTarget(target, AttackSource.Default, true, allowMove, forceAttack);

View File

@@ -968,7 +968,7 @@ namespace OpenRA.Mods.Common.Server
if (!Exts.TryParseIntegerInvariant(parts[1], out var team)) if (!Exts.TryParseIntegerInvariant(parts[1], out var team))
{ {
Log.Write("server", "Invalid team: {0}", s); Log.Write("server", $"Invalid team: {s}");
return false; return false;
} }
@@ -996,7 +996,7 @@ namespace OpenRA.Mods.Common.Server
if (!Exts.TryParseIntegerInvariant(parts[1], out var handicap)) if (!Exts.TryParseIntegerInvariant(parts[1], out var handicap))
{ {
Log.Write("server", "Invalid handicap: {0}", s); Log.Write("server", $"Invalid handicap: {s}");
return false; return false;
} }
@@ -1004,7 +1004,7 @@ namespace OpenRA.Mods.Common.Server
var options = Enumerable.Range(0, 20).Select(i => 5 * i); var options = Enumerable.Range(0, 20).Select(i => 5 * i);
if (!options.Contains(handicap)) if (!options.Contains(handicap))
{ {
Log.Write("server", "Invalid handicap: {0}", s); Log.Write("server", $"Invalid handicap: {s}");
return false; return false;
} }

View File

@@ -30,7 +30,7 @@ namespace OpenRA.Mods.Common.Traits
if (subjectClient == null) if (subjectClient == null)
{ {
Log.Write("debug", "Tick {0}: Order sent to {1}: resolved ClientIndex `{2}` doesn't exist", world.WorldTick, order.Subject.Owner.PlayerName, subjectClientId); Log.Write("debug", $"Tick {world.WorldTick}: Order sent to {order.Subject.Owner.PlayerName}: resolved ClientIndex `{subjectClientId}` doesn't exist");
return false; return false;
} }

View File

@@ -222,8 +222,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
} }
catch catch
{ {
Log.Write("debug", "Map editor ignoring actor {0}, because of missing sprites for tileset {1}.", Log.Write("debug", $"Map editor ignoring actor {actor.Name}, "
actor.Name, World.Map.Rules.TerrainInfo.Id); + $"because of missing sprites for tileset {World.Map.Rules.TerrainInfo.Id}.");
continue; continue;
} }
} }

View File

@@ -29,7 +29,8 @@ namespace OpenRA.Platforms.Default
} }
catch (InvalidOperationException e) catch (InvalidOperationException e)
{ {
Log.Write("sound", "Failed to initialize OpenAL device. Error was {0}", e); Log.Write("sound", "Failed to initialize OpenAL device. Error was");
Log.Write("sound", e);
return new DummySoundEngine(); return new DummySoundEngine();
} }
} }

View File

@@ -65,7 +65,7 @@ namespace OpenRA.Platforms.Default
var devicesPtr = ALC10.alcGetString(IntPtr.Zero, type); var devicesPtr = ALC10.alcGetString(IntPtr.Zero, type);
if (devicesPtr == IntPtr.Zero || AL10.alGetError() != AL10.AL_NO_ERROR) if (devicesPtr == IntPtr.Zero || AL10.alGetError() != AL10.AL_NO_ERROR)
{ {
Log.Write("sound", "Failed to query OpenAL device list using {0}", label); Log.Write("sound", $"Failed to query OpenAL device list using {label}");
return Array.Empty<string>(); return Array.Empty<string>();
} }
@@ -140,7 +140,7 @@ namespace OpenRA.Platforms.Default
AL10.alGenSources(1, out var source); AL10.alGenSources(1, out var source);
if (AL10.alGetError() != AL10.AL_NO_ERROR) if (AL10.alGetError() != AL10.AL_NO_ERROR)
{ {
Log.Write("sound", "Failed generating OpenAL source {0}", i); Log.Write("sound", $"Failed generating OpenAL source {i}");
return; return;
} }

View File

@@ -716,7 +716,7 @@ namespace OpenRA.Platforms.Default
Log.Write("graphics", ""); Log.Write("graphics", "");
Log.Write("graphics", "OpenGL Information:"); Log.Write("graphics", "OpenGL Information:");
var vendor = glGetString(GL_VENDOR); var vendor = glGetString(GL_VENDOR);
Log.Write("graphics", "Vendor: {0}", vendor); Log.Write("graphics", $"Vendor: {vendor}");
if (vendor.Contains("Microsoft")) if (vendor.Contains("Microsoft"))
{ {
var msg = ""; var msg = "";
@@ -725,9 +725,9 @@ namespace OpenRA.Platforms.Default
Log.Write("graphics", msg); Log.Write("graphics", msg);
} }
Log.Write("graphics", "Renderer: {0}", glGetString(GL_RENDERER)); Log.Write("graphics", $"Renderer: {glGetString(GL_RENDERER)}");
Log.Write("graphics", "GL Version: {0}", glGetString(GL_VERSION)); Log.Write("graphics", $"GL Version: {glGetString(GL_VERSION)}");
Log.Write("graphics", "Shader Version: {0}", glGetString(GL_SHADING_LANGUAGE_VERSION)); Log.Write("graphics", $"Shader Version: {glGetString(GL_SHADING_LANGUAGE_VERSION)}");
Log.Write("graphics", "Available extensions:"); Log.Write("graphics", "Available extensions:");
if (Profile != GLProfile.Legacy) if (Profile != GLProfile.Legacy)

View File

@@ -59,7 +59,7 @@ namespace OpenRA.Platforms.Default
var log = new StringBuilder(len); var log = new StringBuilder(len);
OpenGL.glGetShaderInfoLog(shader, len, out _, log); OpenGL.glGetShaderInfoLog(shader, len, out _, log);
Log.Write("graphics", "GL Info Log:\n{0}", log.ToString()); Log.Write("graphics", $"GL Info Log:\n{log}");
throw new InvalidProgramException($"Compile error in shader object '{filename}'"); throw new InvalidProgramException($"Compile error in shader object '{filename}'");
} }
@@ -105,7 +105,7 @@ namespace OpenRA.Platforms.Default
var log = new StringBuilder(len); var log = new StringBuilder(len);
OpenGL.glGetProgramInfoLog(program, len, out _, log); OpenGL.glGetProgramInfoLog(program, len, out _, log);
Log.Write("graphics", "GL Info Log:\n{0}", log.ToString()); Log.Write("graphics", $"GL Info Log:\n{log}");
throw new InvalidProgramException($"Link error in shader program '{name}'"); throw new InvalidProgramException($"Link error in shader program '{name}'");
} }