Skip to content

Commit 47a2ff6

Browse files
committed
Logging
1 parent 27bcff5 commit 47a2ff6

15 files changed

Lines changed: 35 additions & 37 deletions

src/AET.SteamAbstraction/Library/SteamLibrary.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public IEnumerable<SteamAppManifest> GetApps()
6666
}
6767
catch (SteamException e)
6868
{
69-
_logger?.LogWarning(e, $"Could not read game manifest file '{manifestFile}': {e.Message}");
69+
_logger?.LogWarning(e, "Could not read game manifest file '{ManifestFile}': {Message}", manifestFile, e.Message);
7070
}
7171
}
7272
return apps;

src/AET.SteamAbstraction/Library/SteamLibraryFinder.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ public IEnumerable<ISteamLibrary> FindLibraries(IDirectoryInfo steamInstallDir)
4545

4646
private bool TryCreateLibraryFromLocation(IDirectoryInfo libraryLocation, bool isDefault, [NotNullWhen(true)] out SteamLibrary? library)
4747
{
48-
_logger?.LogTrace($"Try creating steam library from location '{libraryLocation.FullName}'");
48+
_logger?.LogTrace("Try creating steam library from location '{Library}'", libraryLocation.FullName);
4949
library = null;
5050

5151
if (!libraryLocation.Exists)
5252
{
53-
_logger?.LogTrace($"Steam library location '{libraryLocation.FullName}' does not exist. Library not created.");
53+
_logger?.LogTrace("Steam library location '{Library}' does not exist. Library not created.", libraryLocation.FullName);
5454
return false;
5555
}
5656

@@ -59,7 +59,7 @@ private bool TryCreateLibraryFromLocation(IDirectoryInfo libraryLocation, bool i
5959
var steamDll = _fileSystem.Path.Combine(libraryLocation.FullName, SteamDllFileName);
6060
if (!_fileSystem.File.Exists(steamDll))
6161
{
62-
_logger?.LogTrace($"Steam library location '{libraryLocation.FullName}' does not contain 'steam.dll'. Library not created.");
62+
_logger?.LogTrace("Steam library location '{Library}' does not contain 'steam.dll'. Library not created.", libraryLocation.FullName);
6363
return false;
6464
}
6565
}
@@ -75,7 +75,7 @@ private bool TryCreateLibraryFromLocation(IDirectoryInfo libraryLocation, bool i
7575
var libraryVdf = _fileSystem.Path.Combine(libraryLocation.FullName, libraryVdfSubPath, libraryVdfName);
7676
if (!_fileSystem.File.Exists(libraryVdf))
7777
{
78-
_logger?.LogTrace($"Steam library VDF file '{libraryVdf}' was not found. Library not created.");
78+
_logger?.LogTrace("Steam library VDF file '{Library}' was not found. Library not created.", libraryVdf);
7979
return false;
8080
}
8181

src/PG.StarWarsGame.Infrastructure/Clients/PetroglyphStarWarsGameClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public IGameProcess Debug(ArgumentCollection arguments, bool fallbackToPlay)
9090
if (!fallbackToPlay)
9191
throw new GameStartException(Game, "Debug version of the game could not be found.");
9292
buildType = GameBuildType.Release;
93-
Logger?.LogTrace($"Falling back to release configuration because debug executables of '{Game}' were not found.");
93+
Logger?.LogTrace("Falling back to release configuration because debug executables of '{Game}' were not found.", Game);
9494
}
9595
return StartGame(arguments, buildType);
9696
}

src/PG.StarWarsGame.Infrastructure/Clients/Processes/GameProcessLauncher.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ public IGameProcess StartGameProcess(IFileInfo executable, GameProcessInfo proce
1818
{
1919
var arguments = ArgumentCommandLineBuilder.BuildCommandLine(processInfo.Arguments);
2020

21-
_logger?.LogDebug(
22-
$"Starting game '{processInfo.Game}' with '{processInfo.BuildType}' configuration and with launch arguments '{arguments}'");
21+
_logger?.LogDebug("Starting game '{Process}' with '{BuildType}' configuration and with launch arguments '{Args}'", processInfo.Game, processInfo.BuildType, arguments);
2322

2423
var processStartInfo = new ProcessStartInfo(executable.FullName)
2524
{

src/PG.StarWarsGame.Infrastructure/Services/Detection/Games/CompositeGameDetector.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public GameDetectionResult Detect(GameType gameType, params ICollection<GamePlat
5656
GameDetectionResult? lastResult = null;
5757
foreach (var detector in SortedDetectors)
5858
{
59-
_logger?.LogTrace($"Searching for game '{gameType}' with detector: '{detector}'");
59+
_logger?.LogTrace("Searching for game '{GameType}' with detector: '{GameDetector}'", gameType, detector);
6060
detector.InitializationRequested += PassThroughInitializationRequest;
6161

6262
try
@@ -70,7 +70,7 @@ public GameDetectionResult Detect(GameType gameType, params ICollection<GamePlat
7070
}
7171
catch (Exception e)
7272
{
73-
_logger?.LogDebug($"Failed detecting game using detector {detector}. {e}");
73+
_logger?.LogDebug("Failed detecting game using detector {GameDetector}. {Exception}", detector, e);
7474
errors.Add(e);
7575

7676
if (detector.Equals(SortedDetectors[^1]))

src/PG.StarWarsGame.Infrastructure/Services/Detection/Games/DirectoryGameDetector.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public sealed class DirectoryGameDetector(IDirectoryInfo directory, IServiceProv
2323
/// <inheritdoc/>
2424
protected override GameLocationData FindGameLocation(GameType gameType)
2525
{
26-
Logger?.LogTrace($"Searching for game {gameType} at directory: {_directory}");
26+
Logger?.LogTrace("Searching for game {GameType} at directory: {DirectoryInfo}", gameType, _directory);
2727
return !MinimumGameFilesExist(gameType, _directory) ? GameLocationData.NotInstalled : new GameLocationData(_directory);
2828
}
2929
}

src/PG.StarWarsGame.Infrastructure/Services/Detection/Games/GameDetectorBase.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public GameDetectionResult Detect(GameType gameType, params ICollection<GamePlat
7676

7777
if (!locationData.IsInstalled)
7878
{
79-
Logger?.LogTrace($"Unable to find an installed game of type {gameType}.");
79+
Logger?.LogTrace("Unable to find an installed game of type {GameType}.", gameType);
8080
return GameDetectionResult.NotInstalled(gameType);
8181
}
8282

@@ -91,20 +91,19 @@ public GameDetectionResult Detect(GameType gameType, params ICollection<GamePlat
9191
// the detector returned a false result.
9292
if (!GameExeExists(location, gameType) || !DataAndMegaFilesXmlExists(location))
9393
{
94-
Logger?.LogTrace($"Unable to find the game's executable or megafiles.xml at the given location: {location.FullName}");
94+
Logger?.LogTrace("Unable to find the game's executable or megafiles.xml at the given location: {Location}", location.FullName);
9595
return GameDetectionResult.NotInstalled(gameType);
9696
}
9797

9898
if (!MatchesOptionsPlatform(platforms, actualPlatform))
9999
{
100100
var wrongGameFound = GameDetectionResult.NotInstalled(gameType);
101-
Logger?.LogTrace($"Game detected at location: {wrongGameFound.GameLocation?.FullName} " +
102-
$"but Platform {actualPlatform} was not requested.");
101+
Logger?.LogTrace("Game detected at location: {Location} but Platform {Platform} was not requested.", wrongGameFound.GameLocation?.FullName, actualPlatform);
103102
return wrongGameFound;
104103
}
105104

106105
var detectedResult = GameDetectionResult.FromInstalled(new GameIdentity(gameType, actualPlatform), location);
107-
Logger?.LogDebug($"Game detected: {detectedResult.GameIdentity} at location: '{location.FullName}'");
106+
Logger?.LogDebug("Game detected: {Identity} at location: '{Location}'", detectedResult.GameIdentity, location.FullName);
108107
return detectedResult;
109108
}
110109

@@ -166,7 +165,7 @@ private bool HandleInitialization(GameType gameType, ref GameLocationData locati
166165
if (!locationData.InitializationRequired)
167166
return true;
168167

169-
Logger?.LogDebug($"It appears that the game '{locationData}' exists but it is not initialized. Game type '{gameType}'.");
168+
Logger?.LogDebug("It appears that the game '{Location}' exists but it is not initialized. Game type '{GameType}'.", locationData, gameType);
170169
if (!_tryHandleInitialization)
171170
return false;
172171

src/PG.StarWarsGame.Infrastructure/Services/Detection/Games/Platform/GamePlatformIdentifier.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ public GamePlatform GetGamePlatform(GameType type, ref IDirectoryInfo location)
4343
foreach (var platform in DefaultGamePlatformOrdering)
4444
{
4545
var validator = GamePlatformIdentifierFactory.Create(platform, _serviceProvider);
46-
_logger?.LogTrace($"Validating location for {platform}...");
46+
_logger?.LogTrace("Validating location for {GamePlatform}...", platform);
4747
if (!validator.IsPlatform(type, ref location))
4848
continue;
4949

50-
_logger?.LogTrace($"Game location was identified as {platform}.");
50+
_logger?.LogTrace("Game location was identified as {GamePlatform}.", platform);
5151
return platform;
5252
}
5353

src/PG.StarWarsGame.Infrastructure/Services/Detection/Games/Platform/OriginIdentifier.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ private void TryFixBrokenFocLocation(ref IDirectoryInfo location)
6666
var correctedPath = location.FileSystem.Path.Combine(parentDir.FullName, "EAWX");
6767
if (!location.FileSystem.Directory.Exists(correctedPath))
6868
{
69-
Logger?.LogTrace($"Unable to sanitize origin path: Corrected path '{correctedPath}' does not exists.");
69+
Logger?.LogTrace("Unable to sanitize origin path: Corrected path '{Path}' does not exists.", correctedPath);
7070
return;
7171
}
7272
location = location.FileSystem.DirectoryInfo.New(correctedPath);

src/PG.StarWarsGame.Infrastructure/Services/Detection/Mods/ModFinder.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public IEnumerable<DetectedModReference> FindMods(IGame game)
2626
throw new ArgumentNullException(nameof(game));
2727
if (!game.Exists())
2828
throw new GameException("The game does not exist");
29-
_logger?.LogDebug($"Searching mods for game '{game}'");
29+
_logger?.LogDebug("Searching mods for game '{Game}'", game);
3030
return GetNormalMods(game).Union(GetWorkshopsMods(game));
3131
}
3232

@@ -40,13 +40,13 @@ public IEnumerable<DetectedModReference> FindMods(IGame game, IDirectoryInfo dir
4040
throw new GameException($"The game '{game}' does not exist");
4141

4242
var modLocationKind = GetModLocationKind(game, directory);
43-
_logger?.LogTrace($"Searching mods with at location '{directory.FullName}' of location kind '{modLocationKind}' for game '{game}'");
43+
_logger?.LogTrace("Searching mods with at location '{Directory}' of location kind '{Kind}' for game '{Game}'", directory.FullName, modLocationKind, game);
4444
return GetModsFromDirectory(directory, modLocationKind, game.Type);
4545
}
4646

4747
private IEnumerable<DetectedModReference> GetNormalMods(IGame game)
4848
{
49-
_logger?.LogTrace($"Searching normal mods for game '{game}'");
49+
_logger?.LogTrace("Searching normal mods for game '{Game}'", game);
5050
return GetAllModsFromContainerPath(game.ModsLocation, ModReferenceBuilder.ModLocationKind.GameModsDirectory, game.Type);
5151
}
5252

@@ -55,7 +55,7 @@ private IEnumerable<DetectedModReference> GetWorkshopsMods(IGame game)
5555
if (game.Platform != GamePlatform.SteamGold)
5656
return [];
5757

58-
_logger?.LogTrace($"Searching Steam Workshop mods for game '{game}'");
58+
_logger?.LogTrace("Searching Steam Workshop mods for game '{Game}'", game);
5959
return GetAllModsFromContainerPath(_steamHelper.GetWorkshopsLocation(game),
6060
ModReferenceBuilder.ModLocationKind.SteamWorkshops, game.Type);
6161
}
@@ -81,7 +81,7 @@ private IEnumerable<DetectedModReference> GetModsFromDirectory(
8181
if (locationKind == ModReferenceBuilder.ModLocationKind.SteamWorkshops && !_steamHelper.ToSteamWorkshopsId(modDirectory.Name, out _))
8282
yield break;
8383

84-
_logger?.LogTrace($"Searching for mods at location '{modDirectory.FullName}'");
84+
_logger?.LogTrace("Searching for mods at location '{Location}'", modDirectory.FullName);
8585

8686
ModinfoFinderCollection modinfoFiles;
8787
modinfoFiles = ModinfoFileFinder.FindModinfoFiles(modDirectory);
@@ -90,7 +90,7 @@ private IEnumerable<DetectedModReference> GetModsFromDirectory(
9090
{
9191
if (_gameTypeResolver.IsDefinitelyNotCompatibleToGame(modRef, requestedGameType))
9292
{
93-
_logger?.LogTrace($"Skipping mod reference '{modRef.ModReference}' because it is not compatible to '{requestedGameType}'");
93+
_logger?.LogTrace("Skipping mod reference '{ModRef}' because it is not compatible to '{GameType}'", modRef.ModReference, requestedGameType);
9494
continue;
9595
}
9696
yield return modRef;

0 commit comments

Comments
 (0)