mirror of
https://github.com/Radarr/Radarr
synced 2025-01-03 05:44:50 +00:00
Test Logging
This commit is contained in:
parent
c221e2097a
commit
207a4b19dc
2 changed files with 17 additions and 2 deletions
|
@ -12,7 +12,7 @@ namespace NzbDrone.Common.Instrumentation
|
||||||
{
|
{
|
||||||
public static class NzbDroneLogger
|
public static class NzbDroneLogger
|
||||||
{
|
{
|
||||||
private const string FILE_LOG_LAYOUT = @"${date:format=yyyy-MM-dd HH\:mm\:ss.f}|${level}|${logger}|${message}${onexception:inner=${newline}${newline}[v${assembly-version}] ${exception:format=ToString}${newline}${exception:format=Data}${newline}}";
|
private const string FILE_LOG_LAYOUT = @"${date:format=yyyy-MM-dd HH\:mm\:ss.fff}|${level}|${logger}|${message}${onexception:inner=${newline}${newline}[v${assembly-version}] ${exception:format=ToString}${newline}${exception:format=Data}${newline}}";
|
||||||
|
|
||||||
private static bool _isConfigured;
|
private static bool _isConfigured;
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using NLog;
|
||||||
using NzbDrone.Common.Extensions;
|
using NzbDrone.Common.Extensions;
|
||||||
using NzbDrone.Core.Datastore.Events;
|
using NzbDrone.Core.Datastore.Events;
|
||||||
using NzbDrone.Core.MediaCover;
|
using NzbDrone.Core.MediaCover;
|
||||||
|
@ -33,6 +34,7 @@ public class CollectionController : RestControllerWithSignalR<CollectionResource
|
||||||
private readonly INamingConfigService _namingService;
|
private readonly INamingConfigService _namingService;
|
||||||
private readonly IMapCoversToLocal _coverMapper;
|
private readonly IMapCoversToLocal _coverMapper;
|
||||||
private readonly IManageCommandQueue _commandQueueManager;
|
private readonly IManageCommandQueue _commandQueueManager;
|
||||||
|
private readonly Logger _logger;
|
||||||
|
|
||||||
public CollectionController(IBroadcastSignalRMessage signalRBroadcaster,
|
public CollectionController(IBroadcastSignalRMessage signalRBroadcaster,
|
||||||
IMovieCollectionService collectionService,
|
IMovieCollectionService collectionService,
|
||||||
|
@ -41,7 +43,8 @@ public CollectionController(IBroadcastSignalRMessage signalRBroadcaster,
|
||||||
IBuildFileNames fileNameBuilder,
|
IBuildFileNames fileNameBuilder,
|
||||||
INamingConfigService namingService,
|
INamingConfigService namingService,
|
||||||
IMapCoversToLocal coverMapper,
|
IMapCoversToLocal coverMapper,
|
||||||
IManageCommandQueue commandQueueManager)
|
IManageCommandQueue commandQueueManager,
|
||||||
|
Logger logger)
|
||||||
: base(signalRBroadcaster)
|
: base(signalRBroadcaster)
|
||||||
{
|
{
|
||||||
_collectionService = collectionService;
|
_collectionService = collectionService;
|
||||||
|
@ -51,6 +54,7 @@ public CollectionController(IBroadcastSignalRMessage signalRBroadcaster,
|
||||||
_namingService = namingService;
|
_namingService = namingService;
|
||||||
_coverMapper = coverMapper;
|
_coverMapper = coverMapper;
|
||||||
_commandQueueManager = commandQueueManager;
|
_commandQueueManager = commandQueueManager;
|
||||||
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override CollectionResource GetResourceById(int id)
|
protected override CollectionResource GetResourceById(int id)
|
||||||
|
@ -62,7 +66,10 @@ protected override CollectionResource GetResourceById(int id)
|
||||||
public List<CollectionResource> GetCollections(int? tmdbId)
|
public List<CollectionResource> GetCollections(int? tmdbId)
|
||||||
{
|
{
|
||||||
var collectionResources = new List<CollectionResource>();
|
var collectionResources = new List<CollectionResource>();
|
||||||
|
|
||||||
|
_logger.Trace("Fetch Cover File Infos");
|
||||||
var coverFileInfos = _coverMapper.GetCoverFileInfos();
|
var coverFileInfos = _coverMapper.GetCoverFileInfos();
|
||||||
|
_logger.Trace("Finished fetching Cover File Infos");
|
||||||
|
|
||||||
if (tmdbId.HasValue)
|
if (tmdbId.HasValue)
|
||||||
{
|
{
|
||||||
|
@ -78,6 +85,8 @@ public List<CollectionResource> GetCollections(int? tmdbId)
|
||||||
collectionResources = MapToResource(_collectionService.GetAllCollections(), coverFileInfos).ToList();
|
collectionResources = MapToResource(_collectionService.GetAllCollections(), coverFileInfos).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_logger.Trace("Returning Collections");
|
||||||
|
|
||||||
return collectionResources;
|
return collectionResources;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,13 +150,18 @@ private IEnumerable<CollectionResource> MapToResource(List<MovieCollection> coll
|
||||||
{
|
{
|
||||||
// Avoid calling for naming spec on every movie in filenamebuilder
|
// Avoid calling for naming spec on every movie in filenamebuilder
|
||||||
var namingConfig = _namingService.GetConfig();
|
var namingConfig = _namingService.GetConfig();
|
||||||
|
|
||||||
|
_logger.Trace("Fetching Movies with Collections");
|
||||||
var collectionMovies = _movieMetadataService.GetMoviesWithCollections();
|
var collectionMovies = _movieMetadataService.GetMoviesWithCollections();
|
||||||
var existingMoviesTmdbIds = _movieService.AllMovieWithCollectionsTmdbIds();
|
var existingMoviesTmdbIds = _movieService.AllMovieWithCollectionsTmdbIds();
|
||||||
|
|
||||||
|
_logger.Trace("Mapping Collections");
|
||||||
foreach (var collection in collections)
|
foreach (var collection in collections)
|
||||||
{
|
{
|
||||||
|
_logger.Trace("Mapping Collection {0}", collection.Title);
|
||||||
var resource = collection.ToResource();
|
var resource = collection.ToResource();
|
||||||
|
|
||||||
|
_logger.Trace("Mapping Collection Movies for {0}", collection.Title);
|
||||||
foreach (var movie in collectionMovies.Where(m => m.CollectionTmdbId == collection.TmdbId))
|
foreach (var movie in collectionMovies.Where(m => m.CollectionTmdbId == collection.TmdbId))
|
||||||
{
|
{
|
||||||
var movieResource = movie.ToResource();
|
var movieResource = movie.ToResource();
|
||||||
|
@ -161,6 +175,7 @@ private IEnumerable<CollectionResource> MapToResource(List<MovieCollection> coll
|
||||||
resource.Movies.Add(movieResource);
|
resource.Movies.Add(movieResource);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_logger.Trace("Mapping Collection Covers for {0}", collection.Title);
|
||||||
MapCoversToLocal(resource.Movies, coverFileInfos);
|
MapCoversToLocal(resource.Movies, coverFileInfos);
|
||||||
|
|
||||||
yield return resource;
|
yield return resource;
|
||||||
|
|
Loading…
Reference in a new issue