refactor: Move CF log logic to a reusable instance object

This replaces the static extension method.
pull/314/head
Robert Dailey 5 months ago
parent 94430f394d
commit 5b9edbfdf5

@ -17,6 +17,7 @@ public class CustomFormatAutofacModule : Module
builder.RegisterType<CustomFormatDataLister>(); builder.RegisterType<CustomFormatDataLister>();
builder.RegisterType<CustomFormatCachePersister>().As<ICachePersister<CustomFormatCache>>(); builder.RegisterType<CustomFormatCachePersister>().As<ICachePersister<CustomFormatCache>>();
builder.RegisterType<CustomFormatTransactionLogger>();
builder.RegisterTypes( builder.RegisterTypes(
typeof(CustomFormatConfigPhase), typeof(CustomFormatConfigPhase),

@ -1,8 +1,8 @@
namespace Recyclarr.Cli.Pipelines.CustomFormat; namespace Recyclarr.Cli.Pipelines.CustomFormat;
internal static class CustomFormatPipelineExtensions internal class CustomFormatTransactionLogger(ILogger log)
{ {
public static void LogTransactions(this CustomFormatPipelineContext context, ILogger log) public void LogTransactions(CustomFormatPipelineContext context)
{ {
var transactions = context.TransactionOutput; var transactions = context.TransactionOutput;

@ -2,7 +2,8 @@ using Recyclarr.Cli.Pipelines.Generic;
namespace Recyclarr.Cli.Pipelines.CustomFormat.PipelinePhases; namespace Recyclarr.Cli.Pipelines.CustomFormat.PipelinePhases;
public class CustomFormatLogPhase(ILogger log) : ILogPipelinePhase<CustomFormatPipelineContext> internal class CustomFormatLogPhase(CustomFormatTransactionLogger cfLogger, ILogger log)
: ILogPipelinePhase<CustomFormatPipelineContext>
{ {
// Returning 'true' means to exit. 'false' means to proceed. // Returning 'true' means to exit. 'false' means to proceed.
public bool LogConfigPhaseAndExitIfNeeded(CustomFormatPipelineContext context) public bool LogConfigPhaseAndExitIfNeeded(CustomFormatPipelineContext context)
@ -23,6 +24,6 @@ public class CustomFormatLogPhase(ILogger log) : ILogPipelinePhase<CustomFormatP
public void LogPersistenceResults(CustomFormatPipelineContext context) public void LogPersistenceResults(CustomFormatPipelineContext context)
{ {
context.LogTransactions(log); cfLogger.LogTransactions(context);
} }
} }

@ -2,10 +2,11 @@ using Recyclarr.Cli.Pipelines.Generic;
namespace Recyclarr.Cli.Pipelines.CustomFormat.PipelinePhases; namespace Recyclarr.Cli.Pipelines.CustomFormat.PipelinePhases;
public class CustomFormatPreviewPhase(ILogger log) : IPreviewPipelinePhase<CustomFormatPipelineContext> internal class CustomFormatPreviewPhase(CustomFormatTransactionLogger logger)
: IPreviewPipelinePhase<CustomFormatPipelineContext>
{ {
public void Execute(CustomFormatPipelineContext context) public void Execute(CustomFormatPipelineContext context)
{ {
context.LogTransactions(log); logger.LogTransactions(context);
} }
} }

Loading…
Cancel
Save