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

@@ -43,7 +43,7 @@ namespace OpenRA
Log.Write("exception", $"Date: {DateTime.UtcNow:u}");
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)");
var rpt = BuildExceptionReport(ex).ToString();

View File

@@ -60,7 +60,7 @@ namespace OpenRA
}
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;
}
}

View File

@@ -176,11 +176,6 @@ namespace OpenRA
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()
{
CancellationToken.Cancel();

View File

@@ -67,10 +67,10 @@ namespace OpenRA.Support
Log.Write("perf", GetHeader(Indentation, name));
foreach (var child in children)
child.Write();
Log.Write("perf", FormatString, ElapsedMs, GetFooter(Indentation));
Log.Write("perf", string.Format(FormatString, ElapsedMs, GetFooter(Indentation)));
}
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;
@@ -79,9 +79,9 @@ namespace OpenRA.Support
{
var type = item.GetType();
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,
"[" + Game.LocalTick + "] " + name + ": " + label);
"[" + Game.LocalTick + "] " + name + ": " + label));
}
public static long LongTickThresholdInStopwatchTicks => (long)(Stopwatch.Frequency * Game.Settings.Debug.LongTickThresholdMs / 1000f);