refactor: Change Log property to field

pull/138/head
Robert Dailey 2 years ago
parent bff81639ce
commit a63d570ec5

@ -15,6 +15,7 @@ internal class CustomFormatUpdater : ICustomFormatUpdater
private readonly IPersistenceProcessor _persistenceProcessor;
private readonly IConsole _console;
private readonly IServerInfo _serverInfo;
private readonly ILogger _log;
public CustomFormatUpdater(
ILogger log,
@ -24,7 +25,7 @@ internal class CustomFormatUpdater : ICustomFormatUpdater
IConsole console,
IServerInfo serverInfo)
{
Log = log;
_log = log;
_cache = cache;
_guideProcessor = guideProcessor;
_persistenceProcessor = persistenceProcessor;
@ -32,8 +33,6 @@ internal class CustomFormatUpdater : ICustomFormatUpdater
_serverInfo = serverInfo;
}
private ILogger Log { get; }
public async Task Process(bool isPreview, IEnumerable<CustomFormatConfig> configs, IGuideService guideService)
{
_cache.Load();
@ -72,28 +71,28 @@ internal class CustomFormatUpdater : ICustomFormatUpdater
{
foreach (var (profileName, scores) in _persistenceProcessor.UpdatedScores)
{
Log.Debug("> Scores updated for quality profile: {ProfileName}", profileName);
_log.Debug("> Scores updated for quality profile: {ProfileName}", profileName);
foreach (var (customFormatName, score, reason) in scores)
{
Log.Debug(" - {Format}: {Score} ({Reason})", customFormatName, score, reason);
_log.Debug(" - {Format}: {Score} ({Reason})", customFormatName, score, reason);
}
}
Log.Information("Updated {ProfileCount} profiles and a total of {ScoreCount} scores",
_log.Information("Updated {ProfileCount} profiles and a total of {ScoreCount} scores",
_persistenceProcessor.UpdatedScores.Keys.Count,
_persistenceProcessor.UpdatedScores.Sum(s => s.Value.Count));
}
else
{
Log.Information("All quality profile scores are already up to date!");
_log.Information("All quality profile scores are already up to date!");
}
if (_persistenceProcessor.InvalidProfileNames.Count > 0)
{
Log.Warning("The following quality profile names are not valid and should either be " +
"removed or renamed in your YAML config");
Log.Warning("{QualityProfileNames}", _persistenceProcessor.InvalidProfileNames);
_log.Warning("The following quality profile names are not valid and should either be " +
"removed or renamed in your YAML config");
_log.Warning("{QualityProfileNames}", _persistenceProcessor.InvalidProfileNames);
}
}
@ -102,39 +101,39 @@ internal class CustomFormatUpdater : ICustomFormatUpdater
var created = transactions.NewCustomFormats;
if (created.Count > 0)
{
Log.Information("Created {Count} New Custom Formats: {CustomFormats}", created.Count,
_log.Information("Created {Count} New Custom Formats: {CustomFormats}", created.Count,
created.Select(r => r.Name));
}
var updated = transactions.UpdatedCustomFormats;
if (updated.Count > 0)
{
Log.Information("Updated {Count} Existing Custom Formats: {CustomFormats}", updated.Count,
_log.Information("Updated {Count} Existing Custom Formats: {CustomFormats}", updated.Count,
updated.Select(r => r.Name));
}
var skipped = transactions.UnchangedCustomFormats;
if (skipped.Count > 0)
{
Log.Debug("Skipped {Count} Custom Formats that did not change: {CustomFormats}", skipped.Count,
_log.Debug("Skipped {Count} Custom Formats that did not change: {CustomFormats}", skipped.Count,
skipped.Select(r => r.Name));
}
var deleted = transactions.DeletedCustomFormatIds;
if (deleted.Count > 0)
{
Log.Information("Deleted {Count} Custom Formats: {CustomFormats}", deleted.Count,
_log.Information("Deleted {Count} Custom Formats: {CustomFormats}", deleted.Count,
deleted.Select(r => r.CustomFormatName));
}
var totalCount = created.Count + updated.Count;
if (totalCount > 0)
{
Log.Information("Total of {Count} custom formats were synced", totalCount);
_log.Information("Total of {Count} custom formats were synced", totalCount);
}
else
{
Log.Information("All custom formats are already up to date!");
_log.Information("All custom formats are already up to date!");
}
}
@ -144,17 +143,17 @@ internal class CustomFormatUpdater : ICustomFormatUpdater
if (_guideProcessor.DuplicatedCustomFormats.Count > 0)
{
Log.Warning("One or more of the custom formats you want are duplicated in the guide. These custom " +
"formats WILL BE SKIPPED. Recyclarr is not able to choose which one you actually " +
"wanted. To resolve this ambiguity, use the `trash_ids` property in your YML " +
"configuration to refer to the custom format using its Trash ID instead of its name");
_log.Warning("One or more of the custom formats you want are duplicated in the guide. These custom " +
"formats WILL BE SKIPPED. Recyclarr is not able to choose which one you actually " +
"wanted. To resolve this ambiguity, use the `trash_ids` property in your YML " +
"configuration to refer to the custom format using its Trash ID instead of its name");
foreach (var (cfName, dupes) in _guideProcessor.DuplicatedCustomFormats)
{
Log.Warning("{CfName} is duplicated {DupeTimes} with the following Trash IDs:", cfName, dupes.Count);
_log.Warning("{CfName} is duplicated {DupeTimes} with the following Trash IDs:", cfName, dupes.Count);
foreach (var cf in dupes)
{
Log.Warning(" - {TrashId}", cf.TrashId);
_log.Warning(" - {TrashId}", cf.TrashId);
}
}
@ -163,11 +162,11 @@ internal class CustomFormatUpdater : ICustomFormatUpdater
if (_guideProcessor.CustomFormatsNotInGuide.Count > 0)
{
Log.Warning("The Custom Formats below do not exist in the guide and will " +
"be skipped. Names must match the 'name' field in the actual JSON, not the header in " +
"the guide! Either fix the names or remove them from your YAML config to resolve this " +
"warning");
Log.Warning("{CfList}", _guideProcessor.CustomFormatsNotInGuide);
_log.Warning("The Custom Formats below do not exist in the guide and will " +
"be skipped. Names must match the 'name' field in the actual JSON, not the header in " +
"the guide! Either fix the names or remove them from your YAML config to resolve this " +
"warning");
_log.Warning("{CfList}", _guideProcessor.CustomFormatsNotInGuide);
_console.Output.WriteLine("");
}
@ -179,8 +178,8 @@ internal class CustomFormatUpdater : ICustomFormatUpdater
if (cfsWithoutQualityProfiles.Count > 0)
{
Log.Debug("These custom formats will be uploaded but are not associated to a quality profile in the " +
"config file: {UnassociatedCfs}", cfsWithoutQualityProfiles);
_log.Debug("These custom formats will be uploaded but are not associated to a quality profile in the " +
"config file: {UnassociatedCfs}", cfsWithoutQualityProfiles);
_console.Output.WriteLine("");
}
@ -188,18 +187,18 @@ internal class CustomFormatUpdater : ICustomFormatUpdater
// No CFs are defined in this item, or they are all invalid. Skip this whole instance.
if (_guideProcessor.ConfigData.Count == 0)
{
Log.Error("Guide processing yielded no custom formats for configured instance host {BaseUrl}",
_log.Error("Guide processing yielded no custom formats for configured instance host {BaseUrl}",
_serverInfo.SanitizedBaseUrl);
return false;
}
if (_guideProcessor.CustomFormatsWithoutScore.Count > 0)
{
Log.Information("The below custom formats have no score in the guide or in your YAML config. They will " +
"still be synced, but no score will be set in your chosen quality profiles");
_log.Information("The below custom formats have no score in the guide or in your YAML config. They will " +
"still be synced, but no score will be set in your chosen quality profiles");
foreach (var tuple in _guideProcessor.CustomFormatsWithoutScore)
{
Log.Information("{CfList}", tuple);
_log.Information("{CfList}", tuple);
}
_console.Output.WriteLine("");
@ -207,13 +206,13 @@ internal class CustomFormatUpdater : ICustomFormatUpdater
if (_guideProcessor.CustomFormatsWithOutdatedNames.Count > 0)
{
Log.Warning("One or more custom format names in your YAML config have been renamed in the guide and " +
"are outdated. Each outdated name will be listed below. These custom formats will refuse " +
"to sync if your cache is deleted. To fix this warning, rename each one to its new name");
_log.Warning("One or more custom format names in your YAML config have been renamed in the guide and " +
"are outdated. Each outdated name will be listed below. These custom formats will refuse " +
"to sync if your cache is deleted. To fix this warning, rename each one to its new name");
foreach (var (oldName, newName) in _guideProcessor.CustomFormatsWithOutdatedNames)
{
Log.Warning(" - '{OldName}' -> '{NewName}'", oldName, newName);
_log.Warning(" - '{OldName}' -> '{NewName}'", oldName, newName);
}
_console.Output.WriteLine("");
@ -260,7 +259,7 @@ internal class CustomFormatUpdater : ICustomFormatUpdater
if (matchingCf == null)
{
Log.Warning("Quality Profile refers to CF not found in guide: {TrashId}",
_log.Warning("Quality Profile refers to CF not found in guide: {TrashId}",
customFormat.TrashId);
continue;
}

Loading…
Cancel
Save