| | | 1 | | using ConsoleLogStreaming.Core.DependencyInjection; |
| | | 2 | | using ConsoleLogStreaming.Core.Options; |
| | | 3 | | using CShells.Lifecycle; |
| | | 4 | | using Elsa.Diagnostics.ConsoleLogs.RealTime; |
| | | 5 | | using Elsa.Diagnostics.ConsoleLogs.Services; |
| | | 6 | | using Microsoft.Extensions.DependencyInjection; |
| | | 7 | | using Microsoft.Extensions.DependencyInjection.Extensions; |
| | | 8 | | |
| | | 9 | | namespace Elsa.Diagnostics.ConsoleLogs.Extensions; |
| | | 10 | | |
| | | 11 | | public static class ServiceCollectionExtensions |
| | | 12 | | { |
| | | 13 | | /// <summary> |
| | | 14 | | /// Registers shell-level console-log consumers and exposes the process-wide capture pipeline through DI. |
| | | 15 | | /// </summary> |
| | | 16 | | public static IServiceCollection AddConsoleLogsServices(this IServiceCollection services, Action<ConsoleLogOptions>? |
| | | 17 | | { |
| | 8 | 18 | | services.AddConsoleLogContextServices(); |
| | 8 | 19 | | services.AddConsoleLogStreaming(options => |
| | 8 | 20 | | { |
| | 8 | 21 | | ElsaConsoleLogOptions.ConfigureDefaults(options); |
| | 8 | 22 | | configureOptions?.Invoke(options); |
| | 10 | 23 | | }); |
| | 8 | 24 | | services.AddSignalR(); |
| | 8 | 25 | | services.DecorateConsoleLogProvider(); |
| | 8 | 26 | | services.TryAddSingleton<IElsaConsoleLogHubAuthorizer, ElsaConsoleLogStreamHubAuthorizer>(); |
| | 8 | 27 | | services.TryAddSingleton<ElsaConsoleLogSubscriptionManager>(); |
| | 8 | 28 | | services.TryAddScoped<ConsoleLogCaptureShellLease>(); |
| | 8 | 29 | | services.TryAddEnumerable(ServiceDescriptor.Scoped<IShellInitializer, ConsoleLogCaptureShellInitializer>()); |
| | 8 | 30 | | services.TryAddEnumerable(ServiceDescriptor.Scoped<IDrainHandler, ConsoleLogCaptureShellDrainHandler>()); |
| | | 31 | | |
| | 8 | 32 | | return services; |
| | | 33 | | } |
| | | 34 | | } |