-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
933 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
using Microsoft.Extensions.Hosting; | ||
using Microsoft.Extensions.Logging; | ||
using Shuttle.Core.Contract; | ||
using Shuttle.Core.Pipelines; | ||
using System.Threading.Tasks; | ||
using System.Threading; | ||
using System; | ||
|
||
namespace Shuttle.Recall.Logging | ||
{ | ||
public class AddProjectionPipelineLogger : IHostedService | ||
{ | ||
private readonly Type _pipelineType = typeof(AddProjectionPipeline); | ||
private readonly ILogger<AddProjectionPipelineLogger> _logger; | ||
private readonly IPipelineFactory _pipelineFactory; | ||
private readonly IRecallLoggingConfiguration _recallLoggingConfiguration; | ||
|
||
public AddProjectionPipelineLogger(ILogger<AddProjectionPipelineLogger> logger, IRecallLoggingConfiguration recallLoggingConfiguration, IPipelineFactory pipelineFactory) | ||
{ | ||
_logger = Guard.AgainstNull(logger, nameof(logger)); | ||
_recallLoggingConfiguration = Guard.AgainstNull(recallLoggingConfiguration, nameof(recallLoggingConfiguration)); | ||
_pipelineFactory = Guard.AgainstNull(pipelineFactory, nameof(pipelineFactory)); | ||
|
||
if (_recallLoggingConfiguration.ShouldLogPipelineType(_pipelineType)) | ||
{ | ||
_pipelineFactory.PipelineCreated += OnPipelineCreated; | ||
} | ||
} | ||
|
||
public async Task StartAsync(CancellationToken cancellationToken) | ||
{ | ||
await Task.CompletedTask; | ||
} | ||
|
||
private void OnPipelineCreated(object sender, PipelineEventArgs args) | ||
{ | ||
if (args.Pipeline.GetType() != _pipelineType) | ||
{ | ||
return; | ||
} | ||
|
||
args.Pipeline.RegisterObserver(new AddProjectionPipelineObserver(_logger, _recallLoggingConfiguration)); | ||
} | ||
|
||
public async Task StopAsync(CancellationToken cancellationToken) | ||
{ | ||
if (_recallLoggingConfiguration.ShouldLogPipelineType(_pipelineType)) | ||
{ | ||
_pipelineFactory.PipelineCreated -= OnPipelineCreated; | ||
|
||
} | ||
|
||
await Task.CompletedTask; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using System.Threading.Tasks; | ||
using Microsoft.Extensions.Logging; | ||
using Shuttle.Core.Pipelines; | ||
|
||
namespace Shuttle.Recall.Logging | ||
{ | ||
public class AddProjectionPipelineObserver : PipelineObserver<AddProjectionPipelineLogger>, | ||
IPipelineObserver<OnBeforeAddProjection>, | ||
IPipelineObserver<OnAddProjection>, | ||
IPipelineObserver<OnAfterAddProjection> | ||
{ | ||
public AddProjectionPipelineObserver(ILogger<AddProjectionPipelineLogger> logger, IRecallLoggingConfiguration recallLoggingConfiguration) : base(logger, recallLoggingConfiguration) | ||
{ | ||
} | ||
|
||
public void Execute(OnBeforeAddProjection pipelineEvent) | ||
{ | ||
Trace(pipelineEvent).GetAwaiter().GetResult(); | ||
} | ||
|
||
public async Task ExecuteAsync(OnBeforeAddProjection pipelineEvent) | ||
{ | ||
await Trace(pipelineEvent); | ||
} | ||
|
||
public void Execute(OnAddProjection pipelineEvent) | ||
{ | ||
Trace(pipelineEvent).GetAwaiter().GetResult(); | ||
} | ||
|
||
public async Task ExecuteAsync(OnAddProjection pipelineEvent) | ||
{ | ||
await Trace(pipelineEvent); | ||
} | ||
|
||
public void Execute(OnAfterAddProjection pipelineEvent) | ||
{ | ||
Trace(pipelineEvent).GetAwaiter().GetResult(); | ||
} | ||
|
||
public async Task ExecuteAsync(OnAfterAddProjection pipelineEvent) | ||
{ | ||
await Trace(pipelineEvent); | ||
} | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
Shuttle.Recall.Logging/AssembleEventEnvelopePipelineLogger.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
using Microsoft.Extensions.Hosting; | ||
using Microsoft.Extensions.Logging; | ||
using Shuttle.Core.Contract; | ||
using Shuttle.Core.Pipelines; | ||
using System.Threading.Tasks; | ||
using System.Threading; | ||
using System; | ||
|
||
namespace Shuttle.Recall.Logging | ||
{ | ||
public class AssembleEventEnvelopePipelineLogger : IHostedService | ||
{ | ||
private readonly Type _pipelineType = typeof(AssembleEventEnvelopePipeline); | ||
private readonly ILogger<AssembleEventEnvelopePipelineLogger> _logger; | ||
private readonly IPipelineFactory _pipelineFactory; | ||
private readonly IRecallLoggingConfiguration _recallLoggingConfiguration; | ||
|
||
public AssembleEventEnvelopePipelineLogger(ILogger<AssembleEventEnvelopePipelineLogger> logger, IRecallLoggingConfiguration recallLoggingConfiguration, IPipelineFactory pipelineFactory) | ||
{ | ||
_logger = Guard.AgainstNull(logger, nameof(logger)); | ||
_recallLoggingConfiguration = Guard.AgainstNull(recallLoggingConfiguration, nameof(recallLoggingConfiguration)); | ||
_pipelineFactory = Guard.AgainstNull(pipelineFactory, nameof(pipelineFactory)); | ||
|
||
if (_recallLoggingConfiguration.ShouldLogPipelineType(_pipelineType)) | ||
{ | ||
_pipelineFactory.PipelineCreated += OnPipelineCreated; | ||
} | ||
} | ||
|
||
public async Task StartAsync(CancellationToken cancellationToken) | ||
{ | ||
await Task.CompletedTask; | ||
} | ||
|
||
private void OnPipelineCreated(object sender, PipelineEventArgs args) | ||
{ | ||
if (args.Pipeline.GetType() != _pipelineType) | ||
{ | ||
return; | ||
} | ||
|
||
args.Pipeline.RegisterObserver(new AssembleEventEnvelopePipelineObserver(_logger, _recallLoggingConfiguration)); | ||
} | ||
|
||
public async Task StopAsync(CancellationToken cancellationToken) | ||
{ | ||
if (_recallLoggingConfiguration.ShouldLogPipelineType(_pipelineType)) | ||
{ | ||
_pipelineFactory.PipelineCreated -= OnPipelineCreated; | ||
|
||
} | ||
|
||
await Task.CompletedTask; | ||
} | ||
} | ||
} |
101 changes: 101 additions & 0 deletions
101
Shuttle.Recall.Logging/AssembleEventEnvelopePipelineObserver.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
using System.Threading.Tasks; | ||
using Microsoft.Extensions.Logging; | ||
using Shuttle.Core.Pipelines; | ||
|
||
namespace Shuttle.Recall.Logging | ||
{ | ||
public class AssembleEventEnvelopePipelineObserver : PipelineObserver<AssembleEventEnvelopePipelineLogger>, | ||
IPipelineObserver<OnAssembleEventEnvelope>, | ||
IPipelineObserver<OnAfterAssembleEventEnvelope>, | ||
IPipelineObserver<OnSerializeEvent>, | ||
IPipelineObserver<OnAfterSerializeEvent>, | ||
IPipelineObserver<OnEncryptEvent>, | ||
IPipelineObserver<OnAfterEncryptEvent>, | ||
IPipelineObserver<OnCompressEvent>, | ||
IPipelineObserver<OnAfterCompressEvent> | ||
{ | ||
public AssembleEventEnvelopePipelineObserver(ILogger<AssembleEventEnvelopePipelineLogger> logger, IRecallLoggingConfiguration recallLoggingConfiguration) : base(logger, recallLoggingConfiguration) | ||
{ | ||
} | ||
|
||
public void Execute(OnAssembleEventEnvelope pipelineEvent) | ||
{ | ||
Trace(pipelineEvent).GetAwaiter().GetResult(); | ||
} | ||
|
||
public async Task ExecuteAsync(OnAssembleEventEnvelope pipelineEvent) | ||
{ | ||
await Trace(pipelineEvent); | ||
} | ||
|
||
public void Execute(OnAfterAssembleEventEnvelope pipelineEvent) | ||
{ | ||
Trace(pipelineEvent).GetAwaiter().GetResult(); | ||
} | ||
|
||
public async Task ExecuteAsync(OnAfterAssembleEventEnvelope pipelineEvent) | ||
{ | ||
await Trace(pipelineEvent); | ||
} | ||
|
||
public void Execute(OnSerializeEvent pipelineEvent) | ||
{ | ||
Trace(pipelineEvent).GetAwaiter().GetResult(); | ||
} | ||
|
||
public async Task ExecuteAsync(OnSerializeEvent pipelineEvent) | ||
{ | ||
await Trace(pipelineEvent); | ||
} | ||
|
||
public void Execute(OnAfterSerializeEvent pipelineEvent) | ||
{ | ||
Trace(pipelineEvent).GetAwaiter().GetResult(); | ||
} | ||
|
||
public async Task ExecuteAsync(OnAfterSerializeEvent pipelineEvent) | ||
{ | ||
await Trace(pipelineEvent); | ||
} | ||
|
||
public void Execute(OnEncryptEvent pipelineEvent) | ||
{ | ||
Trace(pipelineEvent).GetAwaiter().GetResult(); | ||
} | ||
|
||
public async Task ExecuteAsync(OnEncryptEvent pipelineEvent) | ||
{ | ||
await Trace(pipelineEvent); | ||
} | ||
|
||
public void Execute(OnAfterEncryptEvent pipelineEvent) | ||
{ | ||
Trace(pipelineEvent).GetAwaiter().GetResult(); | ||
} | ||
|
||
public async Task ExecuteAsync(OnAfterEncryptEvent pipelineEvent) | ||
{ | ||
await Trace(pipelineEvent); | ||
} | ||
|
||
public void Execute(OnCompressEvent pipelineEvent) | ||
{ | ||
Trace(pipelineEvent).GetAwaiter().GetResult(); | ||
} | ||
|
||
public async Task ExecuteAsync(OnCompressEvent pipelineEvent) | ||
{ | ||
await Trace(pipelineEvent); | ||
} | ||
|
||
public void Execute(OnAfterCompressEvent pipelineEvent) | ||
{ | ||
Trace(pipelineEvent).GetAwaiter().GetResult(); | ||
} | ||
|
||
public async Task ExecuteAsync(OnAfterCompressEvent pipelineEvent) | ||
{ | ||
await Trace(pipelineEvent); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
Shuttle.Recall.Logging/EventProcessorStartupPipelineLogger.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
using Microsoft.Extensions.Hosting; | ||
using Microsoft.Extensions.Logging; | ||
using Shuttle.Core.Contract; | ||
using Shuttle.Core.Pipelines; | ||
using System.Threading.Tasks; | ||
using System.Threading; | ||
using System; | ||
|
||
namespace Shuttle.Recall.Logging | ||
{ | ||
public class EventProcessorStartupPipelineLogger : IHostedService | ||
{ | ||
private readonly Type _pipelineType = typeof(EventProcessorStartupPipeline); | ||
private readonly ILogger<EventProcessorStartupPipelineLogger> _logger; | ||
private readonly IPipelineFactory _pipelineFactory; | ||
private readonly IRecallLoggingConfiguration _recallLoggingConfiguration; | ||
|
||
public EventProcessorStartupPipelineLogger(ILogger<EventProcessorStartupPipelineLogger> logger, IRecallLoggingConfiguration recallLoggingConfiguration, IPipelineFactory pipelineFactory) | ||
{ | ||
_logger = Guard.AgainstNull(logger, nameof(logger)); | ||
_recallLoggingConfiguration = Guard.AgainstNull(recallLoggingConfiguration, nameof(recallLoggingConfiguration)); | ||
_pipelineFactory = Guard.AgainstNull(pipelineFactory, nameof(pipelineFactory)); | ||
|
||
if (_recallLoggingConfiguration.ShouldLogPipelineType(_pipelineType)) | ||
{ | ||
_pipelineFactory.PipelineCreated += OnPipelineCreated; | ||
} | ||
} | ||
|
||
public async Task StartAsync(CancellationToken cancellationToken) | ||
{ | ||
await Task.CompletedTask; | ||
} | ||
|
||
private void OnPipelineCreated(object sender, PipelineEventArgs args) | ||
{ | ||
if (args.Pipeline.GetType() != _pipelineType) | ||
{ | ||
return; | ||
} | ||
|
||
args.Pipeline.RegisterObserver(new EventProcessorStartupPipelineObserver(_logger, _recallLoggingConfiguration)); | ||
} | ||
|
||
public async Task StopAsync(CancellationToken cancellationToken) | ||
{ | ||
if (_recallLoggingConfiguration.ShouldLogPipelineType(_pipelineType)) | ||
{ | ||
_pipelineFactory.PipelineCreated -= OnPipelineCreated; | ||
|
||
} | ||
|
||
await Task.CompletedTask; | ||
} | ||
} | ||
} |
Oops, something went wrong.