| | | 1 | | using Elsa.Diagnostics.StructuredLogs.Contracts; |
| | | 2 | | using Elsa.Diagnostics.StructuredLogs.Logging; |
| | | 3 | | using Elsa.Diagnostics.StructuredLogs.Options; |
| | | 4 | | using Elsa.Diagnostics.StructuredLogs.Providers.InMemory; |
| | | 5 | | using Elsa.Diagnostics.StructuredLogs.RealTime; |
| | | 6 | | using Elsa.Diagnostics.StructuredLogs.Services; |
| | | 7 | | using Microsoft.Extensions.DependencyInjection; |
| | | 8 | | using Microsoft.Extensions.DependencyInjection.Extensions; |
| | | 9 | | using Microsoft.Extensions.Logging; |
| | | 10 | | |
| | | 11 | | namespace Elsa.Diagnostics.StructuredLogs.Extensions; |
| | | 12 | | |
| | | 13 | | public static class ServiceCollectionExtensions |
| | | 14 | | { |
| | | 15 | | public static IServiceCollection AddStructuredLogsServices(this IServiceCollection services, Action<StructuredLogsOp |
| | | 16 | | { |
| | 3 | 17 | | if (configureOptions != null) |
| | 1 | 18 | | services.Configure(configureOptions); |
| | | 19 | | |
| | 3 | 20 | | services.AddSignalR(); |
| | 3 | 21 | | services.AddOptions<StructuredLogsOptions>(); |
| | 3 | 22 | | services.TryAddSingleton<IStructuredLogSourceRegistry, StructuredLogSourceRegistry>(); |
| | 3 | 23 | | services.TryAddSingleton<IStructuredLogRedactor, StructuredLogRedactor>(); |
| | 3 | 24 | | services.TryAddSingleton<InMemoryStructuredLogStore>(); |
| | 5 | 25 | | services.TryAddSingleton<IStructuredLogStore>(sp => sp.GetRequiredService<InMemoryStructuredLogStore>()); |
| | 3 | 26 | | services.TryAddSingleton<InMemoryStructuredLogLiveFeed>(); |
| | 5 | 27 | | services.TryAddSingleton<IStructuredLogLiveFeed>(sp => sp.GetRequiredService<InMemoryStructuredLogLiveFeed>()); |
| | 3 | 28 | | services.TryAddSingleton<IStructuredLogProvider, DefaultStructuredLogProvider>(); |
| | 3 | 29 | | services.TryAddSingleton<StructuredLogSubscriptionManager>(); |
| | 3 | 30 | | services.TryAddEnumerable(ServiceDescriptor.Singleton<ILoggerProvider, StructuredLogLoggerProvider>()); |
| | | 31 | | |
| | 3 | 32 | | return services; |
| | | 33 | | } |
| | | 34 | | } |