public static ConsumerPipelineContext CreateSubstitute( IRawInboundEnvelope?envelope = null, IServiceProvider?serviceProvider = null, IConsumerTransactionManager?transactionManager = null, IConsumer?consumer = null, ISequenceStore?sequenceStore = null, IConsumerEndpoint?endpoint = null) =>
public static void LogConsumerFatalError( this ISilverbackLogger logger, IConsumer?consumer, Exception exception) => ConsumerFatalError( logger.InnerLogger, consumer?.Id ?? "?", consumer?.Endpoint.DisplayName ?? "?", exception);
public static async Task ExecuteAndTraceConsumerActionAsync( this ISilverbackLogger logger, IConsumer?consumer, Func <Task> action, string enterMessage, string successMessage, string errorMessage, Func <object?[]>?argumentsProvider = null) { if (!logger.IsEnabled(IntegrationLogEvents.LowLevelTracing)) { await action.Invoke().ConfigureAwait(false); return; } var args = new List <object?>(argumentsProvider?.Invoke() ?? Array.Empty <object>()); args.Add(consumer?.Id ?? string.Empty); args.Add(consumer?.Endpoint.DisplayName ?? string.Empty); logger.InnerLogger.Log( IntegrationLogEvents.LowLevelTracing.Level, IntegrationLogEvents.LowLevelTracing.EventId, enterMessage + GetConsumerMessageDataString(), args.ToArray()); try { await action.Invoke().ConfigureAwait(false); logger.InnerLogger.Log( IntegrationLogEvents.LowLevelTracing.Level, IntegrationLogEvents.LowLevelTracing.EventId, successMessage + GetConsumerMessageDataString(), args.ToArray()); } catch (Exception ex) { logger.InnerLogger.Log( IntegrationLogEvents.LowLevelTracing.Level, IntegrationLogEvents.LowLevelTracing.EventId, ex, errorMessage + GetConsumerMessageDataString(), args.ToArray()); throw; } }
public static Task ExecuteAndTraceConsumerActionAsync( this ISilverbackLogger logger, IConsumer?consumer, Func <Task> action, string enterMessage, string exitMessage, Func <object?[]>?argumentsProvider = null) => ExecuteAndTraceConsumerActionAsync( logger, consumer, action, enterMessage, exitMessage, exitMessage, argumentsProvider);
public static ConsumerPipelineContext CreateSubstitute( IRawInboundEnvelope?envelope = null, IServiceProvider?serviceProvider = null, IConsumerTransactionManager?transactionManager = null, IConsumer?consumer = null, ISequenceStore?sequenceStore = null, IConsumerEndpoint?endpoint = null) => new ConsumerPipelineContext( envelope ?? new RawInboundEnvelope( Stream.Null, Array.Empty <MessageHeader>(), endpoint ?? new TestConsumerEndpoint("test"), endpoint?.Name ?? "test", new TestOffset()), consumer ?? Substitute.For <IConsumer>(), sequenceStore ?? Substitute.For <ISequenceStore>(), serviceProvider ?? GetServiceProvider()) { TransactionManager = transactionManager ?? Substitute.For <IConsumerTransactionManager>() };
public static void LogConsumerLowLevelTrace( this ISilverbackLogger logger, IConsumer?consumer, string message, Func <object?[]>?argumentsProvider = null) { if (!logger.IsEnabled(IntegrationLogEvents.LowLevelTracing)) { return; } var args = new List <object?>(argumentsProvider?.Invoke() ?? Array.Empty <object>()); args.Add(consumer?.Id ?? string.Empty); args.Add(consumer?.Endpoint.DisplayName ?? string.Empty); logger.InnerLogger.Log( IntegrationLogEvents.LowLevelTracing.Level, IntegrationLogEvents.LowLevelTracing.EventId, message + GetConsumerMessageDataString(), args.ToArray()); }