| | | 1 | | using System.Runtime.CompilerServices; |
| | | 2 | | using Elsa.Diagnostics.StructuredLogs.Contracts; |
| | | 3 | | using Elsa.Diagnostics.StructuredLogs.Models; |
| | | 4 | | |
| | | 5 | | namespace Elsa.Diagnostics.StructuredLogs.Services; |
| | | 6 | | |
| | 7 | 7 | | public class DefaultStructuredLogProvider(IStructuredLogStore store, IStructuredLogLiveFeed liveFeed) : IStructuredLogSt |
| | | 8 | | { |
| | | 9 | | public async ValueTask PublishAsync(StructuredLogEvent logEvent, CancellationToken cancellationToken = default) |
| | | 10 | | { |
| | 1 | 11 | | await store.WriteAsync(logEvent, cancellationToken); |
| | 1 | 12 | | await liveFeed.PublishAsync(logEvent, cancellationToken); |
| | 1 | 13 | | } |
| | | 14 | | |
| | | 15 | | public ValueTask<RecentStructuredLogsResult> GetRecentAsync(StructuredLogFilter filter, CancellationToken cancellati |
| | | 16 | | { |
| | 1 | 17 | | return store.QueryAsync(filter, cancellationToken); |
| | | 18 | | } |
| | | 19 | | |
| | | 20 | | public async IAsyncEnumerable<StructuredLogEvent> SubscribeAsync(StructuredLogFilter filter, [EnumeratorCancellation |
| | | 21 | | { |
| | 8 | 22 | | await foreach (var item in SubscribeWithDroppedEventsAsync(filter, cancellationToken)) |
| | | 23 | | { |
| | 3 | 24 | | if (item.LogEvent != null) |
| | 2 | 25 | | yield return item.LogEvent; |
| | | 26 | | } |
| | 1 | 27 | | } |
| | | 28 | | |
| | | 29 | | public IAsyncEnumerable<StructuredLogStreamItem> SubscribeWithDroppedEventsAsync(StructuredLogFilter filter, Cancell |
| | | 30 | | { |
| | 2 | 31 | | return liveFeed.SubscribeAsync(filter, cancellationToken); |
| | | 32 | | } |
| | | 33 | | |
| | | 34 | | public ValueTask<IReadOnlyCollection<StructuredLogSource>> ListSourcesAsync(CancellationToken cancellationToken = de |
| | | 35 | | { |
| | 1 | 36 | | return store.ListSourcesAsync(cancellationToken); |
| | | 37 | | } |
| | | 38 | | } |