From a13b00d52060a172717b360c8d41e2e334f5423e Mon Sep 17 00:00:00 2001 From: Robert McRackan Date: Thu, 8 Oct 2020 11:48:48 -0400 Subject: [PATCH] - better logging for LoginFailedException - upgrade nuget pkg.s --- ApplicationServices/ApplicationServices.csproj | 2 +- .../UNTESTED/LibraryCommands.cs | 18 ++++++++++++++++++ LibationLauncher/LibationLauncher.csproj | 2 +- LibationLauncher/UNTESTED/Program.cs | 4 ++-- .../InternalUtilities.Tests.csproj | 2 +- 5 files changed, 23 insertions(+), 5 deletions(-) diff --git a/ApplicationServices/ApplicationServices.csproj b/ApplicationServices/ApplicationServices.csproj index e738d34d..7bb291d4 100644 --- a/ApplicationServices/ApplicationServices.csproj +++ b/ApplicationServices/ApplicationServices.csproj @@ -5,7 +5,7 @@ - + diff --git a/ApplicationServices/UNTESTED/LibraryCommands.cs b/ApplicationServices/UNTESTED/LibraryCommands.cs index 68125eac..75536a9f 100644 --- a/ApplicationServices/UNTESTED/LibraryCommands.cs +++ b/ApplicationServices/UNTESTED/LibraryCommands.cs @@ -33,6 +33,24 @@ namespace ApplicationServices return (totalCount, newCount); } + catch (AudibleApi.Authentication.LoginFailedException lfEx) + { + lfEx.MoveResponseBodyFile(FileManager.Configuration.Instance.LibationFiles); + + // nuget Serilog.Exceptions would automatically log custom properties + // However, it comes with a scary warning when used with EntityFrameworkCore which I'm not yet ready to implement: + // https://github.com/RehanSaeed/Serilog.Exceptions + // work-around: use 3rd param. don't just put exception object in 3rd param -- info overload: stack trace, etc + Log.Logger.Error(lfEx, "Error importing library. Login failed. {@DebugInfo}", new { + lfEx.RequestInputFields, + lfEx.RequestUrl, + ResponseStatusCodeNumber = (int)lfEx.ResponseStatusCode, + ResponseStatusCodeDesc = lfEx.ResponseStatusCode, + lfEx.ResponseInputFields, + lfEx.ResponseBodyFilePath + }); + throw; + } catch (Exception ex) { Log.Logger.Error(ex, "Error importing library"); diff --git a/LibationLauncher/LibationLauncher.csproj b/LibationLauncher/LibationLauncher.csproj index 56a877a3..982c18f3 100644 --- a/LibationLauncher/LibationLauncher.csproj +++ b/LibationLauncher/LibationLauncher.csproj @@ -13,7 +13,7 @@ win-x64 - 4.0.11.4 + 4.0.12.4 diff --git a/LibationLauncher/UNTESTED/Program.cs b/LibationLauncher/UNTESTED/Program.cs index 01bccf8f..3271296a 100644 --- a/LibationLauncher/UNTESTED/Program.cs +++ b/LibationLauncher/UNTESTED/Program.cs @@ -323,8 +323,8 @@ namespace LibationLauncher .AddJsonFile(config.SettingsFilePath) .Build(); Log.Logger = new LoggerConfiguration() - .ReadFrom.Configuration(configuration) - .CreateLogger(); + .ReadFrom.Configuration(configuration) + .CreateLogger(); //// MANUAL HARD CODED //Log.Logger = new LoggerConfiguration() diff --git a/_Tests/InternalUtilities.Tests/InternalUtilities.Tests.csproj b/_Tests/InternalUtilities.Tests/InternalUtilities.Tests.csproj index 2da44cc5..2de2579c 100644 --- a/_Tests/InternalUtilities.Tests/InternalUtilities.Tests.csproj +++ b/_Tests/InternalUtilities.Tests/InternalUtilities.Tests.csproj @@ -7,7 +7,7 @@ - +