From a68a025e4aa97cc723e1d1e447a493dd97fa2d8d Mon Sep 17 00:00:00 2001 From: axunonb Date: Thu, 30 May 2024 00:52:18 +0200 Subject: [PATCH 1/2] Fix logging for TournamentCreator --- TournamentManager/TournamentManager/TournamentCreator.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/TournamentManager/TournamentManager/TournamentCreator.cs b/TournamentManager/TournamentManager/TournamentCreator.cs index 6badeeb..d34146d 100644 --- a/TournamentManager/TournamentManager/TournamentCreator.cs +++ b/TournamentManager/TournamentManager/TournamentCreator.cs @@ -234,7 +234,7 @@ public async Task SetTournamentCompleted(long tournamentId, CancellationToken ca if (!await _appDb.MatchRepository.AllMatchesCompletedAsync(new TournamentEntity(tournamentId), cancellationToken)) { var ex = new InvalidOperationException($@"Tournament {tournamentId} contains incomplete matches."); - _logger.LogCritical(ex.Message, ex); + _logger.LogCritical(@"Tournament {tournamentId} contains incomplete matches. {exception}", tournamentId, ex); throw ex; } @@ -253,7 +253,7 @@ public async Task SetTournamentCompleted(long tournamentId, CancellationToken ca if (!await da.SaveEntityAsync(tournament, true, true, cancellationToken)) { var ex = new InvalidOperationException($"Tournament Id {tournamentId} could not be saved to persistent storage."); - _logger.LogCritical(ex.Message, ex); + _logger.LogCritical(@"Tournament Id {tournamentId} could not be saved to persistent storage. {exception}", tournamentId, ex); throw ex; } _logger.LogInformation("Tournament {tournament} set as completed.", tournament); @@ -264,7 +264,7 @@ public virtual async Task SetRoundCompleted(RoundEntity round, CancellationToken if (!await _appDb.MatchRepository.AllMatchesCompletedAsync(round, cancellationToken)) { var ex = new InvalidOperationException($"Round {round.Id} has uncompleted matches."); - _logger.LogCritical(ex.Message, ex); + _logger.LogCritical(@"Round {roundId} has uncompleted matches. {exception}", round.Id, ex); throw ex; } From b783a143b5fb7bafad022fd340108972b1d4ae77 Mon Sep 17 00:00:00 2001 From: axunonb Date: Thu, 30 May 2024 01:05:49 +0200 Subject: [PATCH 2/2] Log parameters in PascalCase --- TournamentManager/TournamentManager/TournamentCreator.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/TournamentManager/TournamentManager/TournamentCreator.cs b/TournamentManager/TournamentManager/TournamentCreator.cs index d34146d..ae7fda2 100644 --- a/TournamentManager/TournamentManager/TournamentCreator.cs +++ b/TournamentManager/TournamentManager/TournamentCreator.cs @@ -234,7 +234,7 @@ public async Task SetTournamentCompleted(long tournamentId, CancellationToken ca if (!await _appDb.MatchRepository.AllMatchesCompletedAsync(new TournamentEntity(tournamentId), cancellationToken)) { var ex = new InvalidOperationException($@"Tournament {tournamentId} contains incomplete matches."); - _logger.LogCritical(@"Tournament {tournamentId} contains incomplete matches. {exception}", tournamentId, ex); + _logger.LogCritical(@"Tournament {TournamentId} contains incomplete matches. {Exception}", tournamentId, ex); throw ex; } @@ -253,10 +253,10 @@ public async Task SetTournamentCompleted(long tournamentId, CancellationToken ca if (!await da.SaveEntityAsync(tournament, true, true, cancellationToken)) { var ex = new InvalidOperationException($"Tournament Id {tournamentId} could not be saved to persistent storage."); - _logger.LogCritical(@"Tournament Id {tournamentId} could not be saved to persistent storage. {exception}", tournamentId, ex); + _logger.LogCritical(@"Tournament Id {TournamentId} could not be saved to persistent storage. {Exception}", tournamentId, ex); throw ex; } - _logger.LogInformation("Tournament {tournament} set as completed.", tournament); + _logger.LogInformation("Tournament {Tournament} set as completed.", tournament); } public virtual async Task SetRoundCompleted(RoundEntity round, CancellationToken cancellationToken) @@ -264,7 +264,7 @@ public virtual async Task SetRoundCompleted(RoundEntity round, CancellationToken if (!await _appDb.MatchRepository.AllMatchesCompletedAsync(round, cancellationToken)) { var ex = new InvalidOperationException($"Round {round.Id} has uncompleted matches."); - _logger.LogCritical(@"Round {roundId} has uncompleted matches. {exception}", round.Id, ex); + _logger.LogCritical(@"Round {RoundId} has uncompleted matches. {Exception}", round.Id, ex); throw ex; }