Skip to content

Commit 7e78cfa

Browse files
committed
better logging perf
1 parent aaa5ef1 commit 7e78cfa

File tree

4 files changed

+19
-17
lines changed

4 files changed

+19
-17
lines changed

src/DiffEngineTray/DiffToolLauncher.cs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ static class DiffToolLauncher
66
public static void Launch(TrackedMove move)
77
{
88
var process = move.Process;
9-
if (process is {HasExited: false})
9+
if (process is { HasExited: false })
1010
{
1111
if (SetForegroundWindow(process.MainWindowHandle))
1212
{
@@ -40,19 +40,22 @@ public static void Launch(TrackedMove move)
4040
}
4141

4242
Log.Error(
43-
$"""
44-
Failed to launch diff tool.
45-
{move.Exe} {move.Arguments}
46-
""");
43+
"""
44+
Failed to launch diff tool.
45+
{Exe} {Arguments}
46+
""",
47+
move.Exe, move.Arguments);
4748
}
4849
catch (Exception exception)
4950
{
5051
Log.Error(
5152
exception,
52-
$"""
53-
Failed to launch diff tool.
54-
{move.Exe} {move.Arguments}
55-
""");
53+
"""
54+
Failed to launch diff tool.
55+
{Exe} {Arguments}
56+
""",
57+
move.Exe,
58+
move.Arguments);
5659
}
5760
}
5861
}

src/DiffEngineTray/FileEx.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public static bool SafeDeleteFile(string path)
1919
}
2020
catch (IOException exception)
2121
{
22-
Log.Error(exception, $"Failed to delete '{path}'.");
22+
Log.Error(exception, "Failed to delete '{Path}'.", path);
2323
//Swallow this since it is likely that a running test it reading or
2424
//writing to the files, and the result will re-add the tracked item
2525
}
@@ -48,7 +48,7 @@ public static void SafeDeleteDirectory(string path)
4848
}
4949
catch (IOException exception)
5050
{
51-
Log.Error(exception, $"Failed to delete '{path}'.");
51+
Log.Error(exception, "Failed to delete '{Path}'.", path);
5252
}
5353
catch (Exception exception)
5454
{
@@ -61,7 +61,7 @@ public static bool SafeMove(string temp, string target)
6161
//Swallow this since it is likely that a running test it reading or
6262
//writing to the files, and the result will re-add the tracked item
6363
void HandleAccessException(Exception exception) =>
64-
Log.Error(exception, $"Failed to move '{temp}' to '{target}'.");
64+
Log.Error(exception, "Failed to move '{Temp}' to '{Target}'.", temp, target);
6565

6666
if (!File.Exists(temp))
6767
{

src/DiffEngineTray/Program.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,8 @@ static void ReBindKeys(Settings settings, KeyRegister keyRegister, Tracker track
125125
}
126126
catch (Exception exception)
127127
{
128-
var message = $"Cannot start. Failed to read settings: {SettingsHelper.FilePath}";
129-
Log.Fatal(exception, message);
130-
IssueLauncher.LaunchForException(message, exception);
128+
Log.Fatal(exception, "Cannot start. Failed to read settings: {FilePath}", SettingsHelper.FilePath);
129+
IssueLauncher.LaunchForException($"Cannot start. Failed to read settings: {SettingsHelper.FilePath}", exception);
131130
return null;
132131
}
133132
}

src/DiffEngineTray/Tracker.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,13 +271,13 @@ static void KillProcesses(TrackedMove move)
271271
{
272272
if (!move.CanKill)
273273
{
274-
Log.Information($"Did not kill for `{move.Name}` since CanKill=false");
274+
Log.Information("Did not kill for `{Name}` since CanKill=false", move.Name);
275275
return;
276276
}
277277

278278
if (move.Process == null)
279279
{
280-
Log.Information($"No processes to kill for `{move.Name}`");
280+
Log.Information("No processes to kill for `{Name}`", move.Name);
281281
return;
282282
}
283283

0 commit comments

Comments
 (0)