Skip to content

Commit

Permalink
Import list logging improvements
Browse files Browse the repository at this point in the history
(cherry picked from commit d2be869d9cee2ee6452a53dcabe20c1598fd115a)

Closes #3850
  • Loading branch information
bakerboy448 authored and mynameisbogdan committed Jul 11, 2023
1 parent f35c8a6 commit db07eba
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions src/NzbDrone.Core/ImportLists/FetchAndParseImportListService.cs
Expand Up @@ -49,10 +49,15 @@ public List<ImportListItemInfo> Fetch()
var importListLocal = importList;
var importListStatus = _importListStatusService.GetLastSyncListInfo(importListLocal.Definition.Id);

if (importListStatus.HasValue && DateTime.UtcNow < importListStatus + importListLocal.MinRefreshInterval)
if (importListStatus.HasValue)
{
_logger.Trace("Skipping refresh of Import List {0} due to minimum refresh inverval", importListLocal.Definition.Name);
continue;
var importListNextSync = importListStatus.Value + importListLocal.MinRefreshInterval;

if (DateTime.UtcNow < importListNextSync)
{
_logger.Trace("Skipping refresh of Import List {0} ({1}) due to minimum refresh interval. Next sync after {2}", importList.Name, importListLocal.Definition.Name, importListNextSync);
continue;
}
}

var task = taskFactory.StartNew(() =>
Expand All @@ -63,7 +68,7 @@ public List<ImportListItemInfo> Fetch()
lock (result)
{
_logger.Debug("Found {0} from {1}", importListReports.Count, importList.Name);
_logger.Debug("Found {0} reports from {1} ({2})", importListReports.Count, importList.Name, importListLocal.Definition.Name);
result.AddRange(importListReports);
}
Expand All @@ -72,7 +77,7 @@ public List<ImportListItemInfo> Fetch()
}
catch (Exception e)
{
_logger.Error(e, "Error during Import List Sync");
_logger.Error(e, "Error during Import List Sync of {0} ({1})", importList.Name, importListLocal.Definition.Name);
}
}).LogExceptions();

Expand All @@ -83,7 +88,7 @@ public List<ImportListItemInfo> Fetch()

result = result.DistinctBy(r => new { r.Artist, r.Album }).ToList();

_logger.Debug("Found {0} reports", result.Count);
_logger.Debug("Found {0} total reports from {1} lists", result.Count, importLists.Count);

return result;
}
Expand All @@ -96,7 +101,7 @@ public List<ImportListItemInfo> FetchSingleList(ImportListDefinition definition)

if (importList == null || !definition.EnableAutomaticAdd)
{
_logger.Debug("Import list not enabled, skipping.");
_logger.Debug("Import List {0} ({1}) is not enabled, skipping.", importList.Name, importList.Definition.Name);
return result;
}

Expand All @@ -121,7 +126,7 @@ public List<ImportListItemInfo> FetchSingleList(ImportListDefinition definition)
lock (result)
{
_logger.Debug("Found {0} from {1}", importListReports.Count, importList.Name);
_logger.Debug("Found {0} reports from {1} ({2})", importListReports.Count, importList.Name, importListLocal.Definition.Name);
result.AddRange(importListReports);
}
Expand All @@ -130,7 +135,7 @@ public List<ImportListItemInfo> FetchSingleList(ImportListDefinition definition)
}
catch (Exception e)
{
_logger.Error(e, "Error during Import List Sync");
_logger.Error(e, "Error during Import List Sync of {0} ({1})", importList.Name, importListLocal.Definition.Name);
}
}).LogExceptions();

Expand Down

0 comments on commit db07eba

Please sign in to comment.