Improve logging

This commit is contained in:
Michael Bucari-Tovo 2022-05-15 11:16:41 -06:00
parent a490df0f7e
commit 8d6d26c9d2

View File

@ -96,6 +96,7 @@ namespace LibationWinForms.ProcessQueue
public async Task<ProcessBookResult> ProcessOneAsync() public async Task<ProcessBookResult> ProcessOneAsync()
{ {
string procName = CurrentProcessable.Name;
try try
{ {
LinkProcessable(CurrentProcessable); LinkProcessable(CurrentProcessable);
@ -106,21 +107,21 @@ namespace LibationWinForms.ProcessQueue
return Result = ProcessBookResult.Success; return Result = ProcessBookResult.Success;
else if (statusHandler.Errors.Contains("Cancelled")) else if (statusHandler.Errors.Contains("Cancelled"))
{ {
Logger.Info($"{CurrentProcessable.Name}: Process was cancelled {LibraryBook.Book}"); Logger.Info($"{procName}: Process was cancelled {LibraryBook.Book}");
return Result = ProcessBookResult.Cancelled; return Result = ProcessBookResult.Cancelled;
} }
else if (statusHandler.Errors.Contains("Validation failed")) else if (statusHandler.Errors.Contains("Validation failed"))
{ {
Logger.Info($"{CurrentProcessable.Name}: Validation failed {LibraryBook.Book}"); Logger.Info($"{procName}: Validation failed {LibraryBook.Book}");
return Result = ProcessBookResult.ValidationFail; return Result = ProcessBookResult.ValidationFail;
} }
foreach (var errorMessage in statusHandler.Errors) foreach (var errorMessage in statusHandler.Errors)
Logger.Error($"{CurrentProcessable.Name}: {errorMessage}"); Logger.Error($"{procName}: {errorMessage}");
} }
catch (Exception ex) catch (Exception ex)
{ {
Logger.Error(ex, CurrentProcessable.Name); Logger.Error(ex, procName);
} }
finally finally
{ {