Much better logging for searching

This commit is contained in:
Mark McDowall 2014-08-01 18:08:02 -07:00
parent c11c2c831d
commit 3b26e82644
2 changed files with 48 additions and 54 deletions

View File

@ -6,7 +6,6 @@ using NzbDrone.Common;
using NzbDrone.Common.Http; using NzbDrone.Common.Http;
using NzbDrone.Core.Indexers.Exceptions; using NzbDrone.Core.Indexers.Exceptions;
using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.IndexerSearch.Definitions;
using NzbDrone.Core.Instrumentation.Extensions;
using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Parser.Model;
using System.Linq; using System.Linq;
@ -46,20 +45,17 @@ namespace NzbDrone.Core.Indexers
public IList<ReleaseInfo> Fetch(IIndexer indexer, SeasonSearchCriteria searchCriteria) public IList<ReleaseInfo> Fetch(IIndexer indexer, SeasonSearchCriteria searchCriteria)
{ {
_logger.Debug("Searching for {0}", searchCriteria); return Fetch(indexer, searchCriteria, 0).DistinctBy(c => c.DownloadUrl).ToList();
var result = Fetch(indexer, searchCriteria, 0).DistinctBy(c => c.DownloadUrl).ToList();
_logger.Info("Finished searching {0} for {1}. Found {2}", indexer, searchCriteria, result.Count);
return result;
} }
private IList<ReleaseInfo> Fetch(IIndexer indexer, SeasonSearchCriteria searchCriteria, int offset) private IList<ReleaseInfo> Fetch(IIndexer indexer, SeasonSearchCriteria searchCriteria, int offset)
{
var searchUrls = indexer.GetSeasonSearchUrls(searchCriteria.QueryTitles, searchCriteria.Series.TvRageId, searchCriteria.SeasonNumber, offset).ToList();
if (searchUrls.Any())
{ {
_logger.Debug("Searching for {0} offset: {1}", searchCriteria, offset); _logger.Debug("Searching for {0} offset: {1}", searchCriteria, offset);
var searchUrls = indexer.GetSeasonSearchUrls(searchCriteria.QueryTitles, searchCriteria.Series.TvRageId, searchCriteria.SeasonNumber, offset).ToList();
var result = Fetch(indexer, searchUrls); var result = Fetch(indexer, searchUrls);
_logger.Info("{0} offset {1}. Found {2}", indexer, offset, result.Count); _logger.Info("{0} offset {1}. Found {2}", indexer, offset, result.Count);
@ -69,52 +65,34 @@ namespace NzbDrone.Core.Indexers
result.AddRange(Fetch(indexer, searchCriteria, offset + indexer.SupportedPageSize)); result.AddRange(Fetch(indexer, searchCriteria, offset + indexer.SupportedPageSize));
} }
//Only log finish for the first call to this recursive method
if (offset == 0)
{
_logger.Info("Finished searching {0} for {1}. Found {2}", indexer, searchCriteria, result.Count);
}
return result; return result;
} }
return new List<ReleaseInfo>();
}
public IList<ReleaseInfo> Fetch(IIndexer indexer, SingleEpisodeSearchCriteria searchCriteria) public IList<ReleaseInfo> Fetch(IIndexer indexer, SingleEpisodeSearchCriteria searchCriteria)
{ {
_logger.Debug("Searching for {0}", searchCriteria);
var searchUrls = indexer.GetEpisodeSearchUrls(searchCriteria.QueryTitles, searchCriteria.Series.TvRageId, searchCriteria.SeasonNumber, searchCriteria.EpisodeNumber).ToList(); var searchUrls = indexer.GetEpisodeSearchUrls(searchCriteria.QueryTitles, searchCriteria.Series.TvRageId, searchCriteria.SeasonNumber, searchCriteria.EpisodeNumber).ToList();
var result = Fetch(indexer, searchUrls); return Fetch(indexer, searchUrls, searchCriteria);
if (searchUrls.Any())
{
_logger.Info("Finished searching {0} for {1}. Found {2}", indexer, searchCriteria, result.Count);
}
return result;
} }
public IList<ReleaseInfo> Fetch(IIndexer indexer, DailyEpisodeSearchCriteria searchCriteria) public IList<ReleaseInfo> Fetch(IIndexer indexer, DailyEpisodeSearchCriteria searchCriteria)
{ {
_logger.Debug("Searching for {0}", searchCriteria);
var searchUrls = indexer.GetDailyEpisodeSearchUrls(searchCriteria.QueryTitles, searchCriteria.Series.TvRageId, searchCriteria.AirDate).ToList(); var searchUrls = indexer.GetDailyEpisodeSearchUrls(searchCriteria.QueryTitles, searchCriteria.Series.TvRageId, searchCriteria.AirDate).ToList();
var result = Fetch(indexer, searchUrls); return Fetch(indexer, searchUrls, searchCriteria);
if (searchUrls.Any())
{
_logger.Info("Finished searching {0} for {1}. Found {2}", indexer, searchCriteria, result.Count);
}
return result;
} }
public IList<ReleaseInfo> Fetch(IIndexer indexer, AnimeEpisodeSearchCriteria searchCriteria) public IList<ReleaseInfo> Fetch(IIndexer indexer, AnimeEpisodeSearchCriteria searchCriteria)
{ {
_logger.Debug("Searching for {0}", searchCriteria);
var searchUrls = indexer.GetAnimeEpisodeSearchUrls(searchCriteria.SceneTitles, searchCriteria.Series.TvRageId, searchCriteria.AbsoluteEpisodeNumber).ToList(); var searchUrls = indexer.GetAnimeEpisodeSearchUrls(searchCriteria.SceneTitles, searchCriteria.Series.TvRageId, searchCriteria.AbsoluteEpisodeNumber).ToList();
var result = Fetch(indexer, searchUrls); return Fetch(indexer, searchUrls, searchCriteria);
if (searchUrls.Any())
{
_logger.Info("Finished searching {0} for {1}. Found {2}", indexer, searchCriteria, result.Count);
}
return result;
} }
public IList<ReleaseInfo> Fetch(IIndexer indexer, SpecialEpisodeSearchCriteria searchCriteria) public IList<ReleaseInfo> Fetch(IIndexer indexer, SpecialEpisodeSearchCriteria searchCriteria)
@ -123,16 +101,32 @@ namespace NzbDrone.Core.Indexers
foreach (var episodeQueryTitle in searchCriteria.EpisodeQueryTitles) foreach (var episodeQueryTitle in searchCriteria.EpisodeQueryTitles)
{ {
_logger.Debug("Performing query of {0} for {1}", indexer, episodeQueryTitle); var urls = indexer.GetSearchUrls(episodeQueryTitle).ToList();
searchUrls.AddRange(indexer.GetSearchUrls(episodeQueryTitle));
}
var result = Fetch(indexer, searchUrls); if (urls.Any())
if (searchUrls.Any())
{ {
_logger.Info("Finished searching {0} for {1}. Found {2}", indexer, searchCriteria, result.Count); _logger.Debug("Performing query of {0} for {1}", indexer, episodeQueryTitle);
searchUrls.AddRange(urls);
} }
}
return Fetch(indexer, searchUrls, searchCriteria);
}
private List<ReleaseInfo> Fetch(IIndexer indexer, IEnumerable<string> urls, SearchCriteriaBase searchCriteria)
{
var urlList = urls.ToList();
if (urlList.Empty())
{
return new List<ReleaseInfo>();
}
_logger.Debug("Searching for {0}", searchCriteria);
var result = Fetch(indexer, urlList);
_logger.Info("Finished searching {0} for {1}. Found {2}", indexer, searchCriteria, result.Count);
return result; return result;
} }

View File

@ -74,13 +74,13 @@ namespace NzbDrone.Core.Jobs
var currentTasks = _scheduledTaskRepository.All().ToList(); var currentTasks = _scheduledTaskRepository.All().ToList();
_logger.Debug("Initializing jobs. Available: {0} Existing: {1}", defaultTasks.Count(), currentTasks.Count()); _logger.Trace("Initializing jobs. Available: {0} Existing: {1}", defaultTasks.Count(), currentTasks.Count());
foreach (var job in currentTasks) foreach (var job in currentTasks)
{ {
if (!defaultTasks.Any(c => c.TypeName == job.TypeName)) if (!defaultTasks.Any(c => c.TypeName == job.TypeName))
{ {
_logger.Debug("Removing job from database '{0}'", job.TypeName); _logger.Trace("Removing job from database '{0}'", job.TypeName);
_scheduledTaskRepository.Delete(job.Id); _scheduledTaskRepository.Delete(job.Id);
} }
} }
@ -109,7 +109,7 @@ namespace NzbDrone.Core.Jobs
if (scheduledTask != null) if (scheduledTask != null)
{ {
_logger.Debug("Updating last run time for: {0}", scheduledTask.TypeName); _logger.Trace("Updating last run time for: {0}", scheduledTask.TypeName);
_scheduledTaskRepository.SetLastExecutionTime(scheduledTask.Id, DateTime.UtcNow); _scheduledTaskRepository.SetLastExecutionTime(scheduledTask.Id, DateTime.UtcNow);
} }
} }