Use C# 10 string interpolation wherever possible

This commit is contained in:
Archi
2021-11-11 01:53:34 +01:00
parent 60376c4d93
commit d1fc7ebb74
20 changed files with 76 additions and 73 deletions

View File

@@ -176,7 +176,7 @@ public sealed class ArchiLogger {
}
// Otherwise, we ran into fatal exception before logging module could even get initialized, so activate fallback logging that involves file and console
string message = string.Format(CultureInfo.CurrentCulture, DateTime.Now + " " + Strings.ErrorEarlyFatalExceptionInfo, SharedInfo.Version) + Environment.NewLine;
string message = $"{DateTime.Now} {string.Format(CultureInfo.CurrentCulture, Strings.ErrorEarlyFatalExceptionInfo, SharedInfo.Version)}{Environment.NewLine}";
try {
await File.WriteAllTextAsync(SharedInfo.LogFile, message).ConfigureAwait(false);
@@ -191,7 +191,7 @@ public sealed class ArchiLogger {
}
while (true) {
message = string.Format(CultureInfo.CurrentCulture, Strings.ErrorEarlyFatalExceptionPrint, previousMethodName, exception.Message, exception.StackTrace) + Environment.NewLine;
message = $"{string.Format(CultureInfo.CurrentCulture, Strings.ErrorEarlyFatalExceptionPrint, previousMethodName, exception.Message, exception.StackTrace)}{Environment.NewLine}";
try {
await File.AppendAllTextAsync(SharedInfo.LogFile, message).ConfigureAwait(false);

View File

@@ -44,7 +44,7 @@ internal static class Logging {
internal const string NLogConfigurationFile = "NLog.config";
private const byte ConsoleResponsivenessDelay = 250; // In milliseconds
private const string GeneralLayout = @"${date:format=yyyy-MM-dd HH\:mm\:ss}|${processname}-${processid}|${level:uppercase=true}|" + LayoutMessage;
private const string GeneralLayout = $@"${{date:format=yyyy-MM-dd HH\:mm\:ss}}|${{processname}}-${{processid}}|${{level:uppercase=true}}|{LayoutMessage}";
private const string LayoutMessage = @"${logger}|${message}${onexception:inner= ${exception:format=toString,Data}}";
private static readonly ConcurrentHashSet<LoggingRule> ConsoleLoggingRules = new();