Skip to content

Commit

Permalink
Add more logging
Browse files Browse the repository at this point in the history
  • Loading branch information
shemanaev committed Sep 19, 2022
1 parent 370a985 commit c3a6487
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
9 changes: 9 additions & 0 deletions MediaCleaner/Filtering/FavoritesFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,24 @@
using MediaBrowser.Controller.Entities.Movies;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Library;
using Microsoft.Extensions.Logging;

namespace MediaCleaner.Filtering;

internal class FavoritesFilter : IExpiredItemFilter
{
private readonly ILogger<FavoritesFilter> _logger;
private readonly FavoriteKeepKind _kind;
private readonly List<User> _users;
private readonly IUserDataManager _userDataManager;

public FavoritesFilter(
ILogger<FavoritesFilter> logger,
FavoriteKeepKind kind,
List<User> users,
IUserDataManager userDataManager)
{
_logger = logger;
_kind = kind;
_users = users;
_userDataManager = userDataManager;
Expand All @@ -44,6 +48,11 @@ public List<ExpiredItem> Apply(List<ExpiredItem> items)
{
result.Add(item);
}
else
{
var user = _users.Find(m => IsFavorite(m, item.Item));
_logger.LogTrace("'{Name}' is favorited by '{Username}'", item.Item.Name, user.Username);
}
break;

case FavoriteKeepKind.AllUsers:
Expand Down
9 changes: 9 additions & 0 deletions MediaCleaner/Filtering/LocationsFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,24 @@
using MediaBrowser.Controller.Entities.Movies;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Model.IO;
using Microsoft.Extensions.Logging;

namespace MediaCleaner.Filtering;

internal class LocationsFilter : IExpiredItemFilter
{
private readonly ILogger<LocationsFilter> _logger;
private readonly LocationsListMode _mode;
private readonly List<string> _locations;
private readonly IFileSystem _fileSystem;

public LocationsFilter(
ILogger<LocationsFilter> logger,
LocationsListMode mode,
List<string> locations,
IFileSystem fileSystem)
{
_logger = logger;
_mode = mode;
_locations = locations;
_fileSystem = fileSystem;
Expand Down Expand Up @@ -53,6 +57,11 @@ public List<ExpiredItem> Apply(List<ExpiredItem> items)
{
result.Add(item);
}
else
{
var location = _locations.Find(s => _fileSystem.ContainsSubPath(s, path));
_logger.LogTrace("'{Name}' is belongs to location '{Location}'", item.Item.Name, location);
}
}

return result;
Expand Down
1 change: 1 addition & 0 deletions MediaCleaner/JunkCollectors/BaseJunkCollector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public virtual List<ExpiredItem> Execute(
.SelectMany(x => _itemsAdapter.GetPlayedItems(_kind, x, cancellationToken))
.ToList();

_logger.LogDebug("Filters order: {Filters}", string.Join(", ", filters.Select(x => x.Name)));
_logger.LogDebug("{Count} items before filtering", items.Count);

foreach (var filter in filters)
Expand Down

0 comments on commit c3a6487

Please sign in to comment.