Skip to content

Commit

Permalink
Enriched Logging with series name (#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
JPVenson authored Jun 19, 2023
1 parent d9b250d commit fe7c84f
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 22 deletions.
9 changes: 5 additions & 4 deletions Jellyfin.Plugin.Tvdb/Providers/TvdbEpisodeImageProvider.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Net.Http;
Expand Down Expand Up @@ -82,10 +82,11 @@ public async Task<IEnumerable<RemoteImageInfo>> GetImages(BaseItem item, Cancell
if (string.IsNullOrEmpty(episodeTvdbId))
{
_logger.LogError(
"Episode {SeasonNumber}x{EpisodeNumber} not found for series {SeriesTvdbId}",
"Episode {SeasonNumber}x{EpisodeNumber} not found for series {SeriesTvdbId}:{Name}",
episode.ParentIndexNumber,
episode.IndexNumber,
series.GetProviderId(TvdbPlugin.ProviderId));
series.GetProviderId(TvdbPlugin.ProviderId),
series.Name);
return imageResult;
}

Expand All @@ -102,7 +103,7 @@ await _tvdbClientManager
}
catch (TvDbServerException e)
{
_logger.LogError(e, "Failed to retrieve episode images for series {TvDbId}", series.GetProviderId(TvdbPlugin.ProviderId));
_logger.LogError(e, "Failed to retrieve episode images for series {TvDbId}:{Name}", series.GetProviderId(TvdbPlugin.ProviderId), series.Name);
}
}

Expand Down
12 changes: 9 additions & 3 deletions Jellyfin.Plugin.Tvdb/Providers/TvdbEpisodeProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,11 @@ private async Task<MetadataResult<Episode>> GetEpisode(EpisodeInfo searchInfo, C
if (string.IsNullOrEmpty(episodeTvdbId))
{
_logger.LogError(
"Episode {SeasonNumber}x{EpisodeNumber} not found for series {SeriesTvdbId}",
"Episode {SeasonNumber}x{EpisodeNumber} not found for series {SeriesTvdbId}:{Name}",
searchInfo.ParentIndexNumber,
searchInfo.IndexNumber,
seriesTvdbId);
seriesTvdbId,
searchInfo.Name);
return result;
}

Expand All @@ -184,7 +185,12 @@ private async Task<MetadataResult<Episode>> GetEpisode(EpisodeInfo searchInfo, C
}
catch (TvDbServerException e)
{
_logger.LogError(e, "Failed to retrieve episode with id {EpisodeTvDbId}, series id {SeriesTvdbId}", episodeTvdbId, seriesTvdbId);
_logger.LogError(
e,
"Failed to retrieve episode with id {EpisodeTvDbId}, series id {SeriesTvdbId}:{Name}",
episodeTvdbId,
seriesTvdbId,
searchInfo.Name);
}

return result;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
Expand Down
2 changes: 1 addition & 1 deletion Jellyfin.Plugin.Tvdb/Providers/TvdbPersonImageProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public Task<HttpResponseMessage> GetImageResponse(string url, CancellationToken
}
catch (TvDbServerException e)
{
_logger.LogError(e, "Failed to retrieve actor {ActorName} from series {SeriesTvdbId}", personName, tvdbId);
_logger.LogError(e, "Failed to retrieve actor {ActorName} from series {SeriesTvdbId}:{Name}", personName, tvdbId, series.Name);
return null;
}
}
Expand Down
2 changes: 1 addition & 1 deletion Jellyfin.Plugin.Tvdb/Providers/TvdbSeasonImageProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public async Task<IEnumerable<RemoteImageInfo>> GetImages(BaseItem item, Cancell
}
catch (TvDbServerException)
{
_logger.LogDebug("No images of type {KeyType} found for series {TvdbId}", keyType, tvdbId);
_logger.LogDebug("No images of type {KeyType} found for series {TvdbId}:{Name}", keyType, tvdbId, item.Name);
}
}

Expand Down
5 changes: 3 additions & 2 deletions Jellyfin.Plugin.Tvdb/Providers/TvdbSeriesImageProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,10 @@ await _tvdbClientManager.GetImagesAsync(tvdbId, imageQuery, language, cancellati
catch (TvDbServerException)
{
_logger.LogDebug(
"No images of type {KeyType} exist for series {TvDbId}",
"No images of type {KeyType} exist for series {TvDbId}:{Name}",
keyType,
tvdbId);
tvdbId,
item.Name);
}
}

Expand Down
29 changes: 19 additions & 10 deletions Jellyfin.Plugin.Tvdb/Providers/TvdbSeriesProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public async Task<MetadataResult<Series>> GetMetadata(SeriesInfo info, Cancellat
{
var result = new MetadataResult<Series>
{
QueriedById = true
QueriedById = true,
};

if (!IsValidSeries(info.ProviderIds))
Expand All @@ -81,7 +81,7 @@ public async Task<MetadataResult<Series>> GetMetadata(SeriesInfo info, Cancellat
result.Item = new Series();
result.HasMetadata = true;

await FetchSeriesMetadata(result, info.MetadataLanguage, info.ProviderIds, cancellationToken)
await FetchSeriesMetadata(result, info, cancellationToken)
.ConfigureAwait(false);
}

Expand Down Expand Up @@ -118,6 +118,7 @@ private async Task<IEnumerable<RemoteSearchResult>> FetchSeriesSearchResult(Seri
imdbId,
MetadataProvider.Imdb.ToString(),
seriesInfo.MetadataLanguage,
seriesInfo.Name,
cancellationToken).ConfigureAwait(false);
}
}
Expand All @@ -131,6 +132,7 @@ private async Task<IEnumerable<RemoteSearchResult>> FetchSeriesSearchResult(Seri
zap2ItId,
MetadataProvider.Zap2It.ToString(),
seriesInfo.MetadataLanguage,
seriesInfo.Name,
cancellationToken).ConfigureAwait(false);
}
}
Expand All @@ -145,7 +147,7 @@ await _tvdbClientManager
}
catch (TvDbServerException e)
{
_logger.LogError(e, "Failed to retrieve series with id {TvdbId}", tvdbId);
_logger.LogError(e, "Failed to retrieve series with id {TvdbId}:{SeriesName}", tvdbId, seriesInfo.Name);
return Array.Empty<RemoteSearchResult>();
}
}
Expand Down Expand Up @@ -177,8 +179,13 @@ private RemoteSearchResult MapSeriesToRemoteSearchResult(TvDbSharper.Dto.Series
return remoteResult;
}

private async Task FetchSeriesMetadata(MetadataResult<Series> result, string metadataLanguage, Dictionary<string, string> seriesProviderIds, CancellationToken cancellationToken)
private async Task FetchSeriesMetadata(
MetadataResult<Series> result,
SeriesInfo info,
CancellationToken cancellationToken)
{
string metadataLanguage = info.MetadataLanguage;
Dictionary<string, string> seriesProviderIds = info.ProviderIds;
var series = result.Item;

if (seriesProviderIds.TryGetValue(TvdbPlugin.ProviderId, out var tvdbId) && !string.IsNullOrEmpty(tvdbId))
Expand All @@ -193,6 +200,7 @@ private async Task FetchSeriesMetadata(MetadataResult<Series> result, string met
imdbId,
MetadataProvider.Imdb.ToString(),
metadataLanguage,
info.Name,
cancellationToken).ConfigureAwait(false);
}

Expand All @@ -203,6 +211,7 @@ private async Task FetchSeriesMetadata(MetadataResult<Series> result, string met
zap2It,
MetadataProvider.Zap2It.ToString(),
metadataLanguage,
info.Name,
cancellationToken).ConfigureAwait(false);
}

Expand All @@ -216,7 +225,7 @@ await _tvdbClientManager
}
catch (TvDbServerException e)
{
_logger.LogError(e, "Failed to retrieve series with id {TvdbId}", tvdbId);
_logger.LogError(e, "Failed to retrieve series with id {TvdbId}:{SeriesName}", tvdbId, info.Name);
return;
}

Expand All @@ -232,11 +241,11 @@ await _tvdbClientManager
}
catch (TvDbServerException e)
{
_logger.LogError(e, "Failed to retrieve actors for series {TvdbId}", tvdbId);
_logger.LogError(e, "Failed to retrieve actors for series {TvdbId}:{SeriesName}", tvdbId, info.Name);
}
}

private async Task<string?> GetSeriesByRemoteId(string id, string idType, string language, CancellationToken cancellationToken)
private async Task<string?> GetSeriesByRemoteId(string id, string idType, string language, string seriesName, CancellationToken cancellationToken)
{
TvDbResponse<SeriesSearchResult[]>? result = null;

Expand All @@ -255,7 +264,7 @@ await _tvdbClientManager
}
catch (TvDbServerException e)
{
_logger.LogError(e, "Failed to retrieve series with remote id {RemoteId}", id);
_logger.LogError(e, "Failed to retrieve series with remote id {RemoteId}:{SeriesName}", id, seriesName);
}

return result?.Data.FirstOrDefault()?.Id.ToString(CultureInfo.InvariantCulture);
Expand Down Expand Up @@ -341,7 +350,7 @@ await _tvdbClientManager.GetSeriesByIdAsync(seriesSearchResult.Id, language, can
}
catch (TvDbServerException e)
{
_logger.LogError(e, "Unable to retrieve series with id {TvdbId}", seriesSearchResult.Id);
_logger.LogError(e, "Unable to retrieve series with id {TvdbId}:{SeriesName}", seriesSearchResult.Id, seriesSearchResult.SeriesName);
}

remoteSearchResult.SetProviderId(TvdbPlugin.ProviderId, seriesSearchResult.Id.ToString(CultureInfo.InvariantCulture));
Expand Down Expand Up @@ -484,7 +493,7 @@ private async Task MapSeriesToResult(MetadataResult<Series> result, TvDbSharper.
}
catch (TvDbServerException e)
{
_logger.LogError(e, "Failed to find series end date for series {TvdbId}", tvdbSeries.Id);
_logger.LogError(e, "Failed to find series end date for series {TvdbId}:{SeriesName}", tvdbSeries.Id, tvdbSeries?.SeriesName ?? result.Item?.Name);
}
}
}
Expand Down

0 comments on commit fe7c84f

Please sign in to comment.