From 1812fc2c7ca640f454f3f72b226aa48e7e7ecf48 Mon Sep 17 00:00:00 2001 From: Robert McRackan Date: Mon, 14 Dec 2020 15:42:27 -0500 Subject: [PATCH] - Increase account privacy in logs - Improve book download retry --- ApplicationServices/UNTESTED/LibraryCommands.cs | 7 ++----- FileLiberator/UNTESTED/DownloadBook.cs | 2 +- InternalUtilities/Account.cs | 6 ++++++ InternalUtilities/UNTESTED/AudibleApiActions.cs | 2 +- LibationLauncher/LibationLauncher.csproj | 2 +- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/ApplicationServices/UNTESTED/LibraryCommands.cs b/ApplicationServices/UNTESTED/LibraryCommands.cs index 06417e82..3ec19cc7 100644 --- a/ApplicationServices/UNTESTED/LibraryCommands.cs +++ b/ApplicationServices/UNTESTED/LibraryCommands.cs @@ -81,16 +81,13 @@ namespace ApplicationServices { ArgumentValidator.EnsureNotNull(account, nameof(account)); - var localeName = account.Locale?.Name; Log.Logger.Information("ImportLibraryAsync. {@DebugInfo}", new { - AccountName = account.AccountName.ToMask(), - AccountId = account.AccountId.ToMask(), - LocaleName = localeName, + Account = account?.MaskedLogEntry ?? "[null]" }); var dtoItems = await AudibleApiActions.GetLibraryValidatedAsync(api); - return dtoItems.Select(d => new ImportItem { DtoItem = d, AccountId = account.AccountId, LocaleName = localeName }).ToList(); + return dtoItems.Select(d => new ImportItem { DtoItem = d, AccountId = account.AccountId, LocaleName = account.Locale?.Name }).ToList(); } private static async Task importIntoDbAsync(List importItems) diff --git a/FileLiberator/UNTESTED/DownloadBook.cs b/FileLiberator/UNTESTED/DownloadBook.cs index 7d90e864..788a9f9f 100644 --- a/FileLiberator/UNTESTED/DownloadBook.cs +++ b/FileLiberator/UNTESTED/DownloadBook.cs @@ -72,7 +72,7 @@ namespace FileLiberator libraryBook.Book.Title, libraryBook.Book.AudibleProductId, libraryBook.Book.Locale, - libraryBook.Account, + Account = libraryBook.Account?.ToMask() ?? "[empty]", tempAaxFilename, actualFilePath, length, diff --git a/InternalUtilities/Account.cs b/InternalUtilities/Account.cs index 12accb88..b350f01f 100644 --- a/InternalUtilities/Account.cs +++ b/InternalUtilities/Account.cs @@ -93,5 +93,11 @@ namespace InternalUtilities } public override string ToString() => $"{AccountId} - {Locale?.Name ?? "[empty]"}"; + + public string MaskedLogEntry => @$"AccountId={mask(AccountId)}|AccountName={mask(AccountName)}|Locale={Locale?.Name ?? "[empty]"}"; + private static string mask(string str) + => str is null ? "[null]" + : str == string.Empty ? "[empty]" + : str.ToMask(); } } diff --git a/InternalUtilities/UNTESTED/AudibleApiActions.cs b/InternalUtilities/UNTESTED/AudibleApiActions.cs index 81257295..d20f7eea 100644 --- a/InternalUtilities/UNTESTED/AudibleApiActions.cs +++ b/InternalUtilities/UNTESTED/AudibleApiActions.cs @@ -32,7 +32,7 @@ namespace InternalUtilities { Serilog.Log.Logger.Information("GetApiAsync. {@DebugInfo}", new { - AccountId = account?.AccountId.ToMask() ?? "[empty]", + Account = account?.MaskedLogEntry ?? "[null]", LocaleName = account?.Locale?.Name }); return EzApiCreator.GetApiAsync( diff --git a/LibationLauncher/LibationLauncher.csproj b/LibationLauncher/LibationLauncher.csproj index ff548d81..e201f74d 100644 --- a/LibationLauncher/LibationLauncher.csproj +++ b/LibationLauncher/LibationLauncher.csproj @@ -13,7 +13,7 @@ win-x64 - 4.1.2.1 + 4.1.2.2