public void LogCannotMoveSequences( ISilverbackLogger logger, IRawInboundEnvelope envelope, ISequence sequence) { if (!logger.IsEnabled(IntegrationLogEvents.CannotMoveSequences)) { return; } (string?value1, string?value2) = _logEnricher.GetAdditionalValues( envelope.Endpoint, envelope.Headers, envelope.BrokerMessageIdentifier); _cannotMoveSequences.Invoke( logger.InnerLogger, sequence.GetType().Name, envelope.ActualEndpointDisplayName, envelope.Headers.GetValue(DefaultMessageHeaders.MessageType), envelope.Headers.GetValue(DefaultMessageHeaders.MessageId), value1, value2, null); }
public void LogProduced( ISilverbackLogger logger, IProducerEndpoint endpoint, string actualEndpoint, IReadOnlyCollection <MessageHeader>?headers, IBrokerMessageIdentifier?brokerMessageIdentifier) { if (!logger.IsEnabled(IntegrationLogEvents.MessageProduced)) { return; } (string?value1, string?value2) = _logEnricher.GetAdditionalValues( endpoint, headers, brokerMessageIdentifier); _messageProduced.Invoke( logger.InnerLogger, actualEndpoint, headers?.GetValue(DefaultMessageHeaders.MessageType), headers?.GetValue(DefaultMessageHeaders.MessageId), value1, value2, null); }
public void LogProduceError( ISilverbackLogger logger, IProducerEndpoint endpoint, string actualEndpoint, IReadOnlyCollection <MessageHeader>?headers, Exception exception) { if (!logger.IsEnabled(IntegrationLogEvents.MessageProduced)) { return; } (string?value1, string?value2) = _logEnricher.GetAdditionalValues( endpoint, headers, null); _errorProducingMessage.Invoke( logger.InnerLogger, actualEndpoint, headers?.GetValue(DefaultMessageHeaders.MessageType), headers?.GetValue(DefaultMessageHeaders.MessageId), value1, value2, exception); }
public void LogInboundTrace( ISilverbackLogger logger, LogLevel logLevel, EventId eventId, string message, IRawInboundEnvelope envelope, Exception?exception, Func <object?[]>?argumentsProvider = null) { if (!logger.IsEnabled(IntegrationLogEvents.LowLevelTracing)) { return; } (string?value1, string?value2) = _logEnricher.GetAdditionalValues( envelope.Endpoint, envelope.Headers, envelope.BrokerMessageIdentifier); var args = new List <object?>(argumentsProvider?.Invoke() ?? Array.Empty <object?>()); args.Add(envelope.ActualEndpointDisplayName); args.Add(envelope.Headers.GetValue(DefaultMessageHeaders.MessageType)); args.Add(envelope.Headers.GetValue(DefaultMessageHeaders.MessageId)); args.Add(value1); args.Add(value2); logger.InnerLogger.Log( logLevel, eventId, exception, EnrichMessage(message), args.ToArray()); }
public void LogMoved( ISilverbackLogger logger, IRawInboundEnvelope envelope, IProducerEndpoint targetEndpoint) { if (!logger.IsEnabled(IntegrationLogEvents.MessageMoved)) { return; } (string?value1, string?value2) = _logEnricher.GetAdditionalValues( envelope.Endpoint, envelope.Headers, envelope.BrokerMessageIdentifier); _messageMoved.Invoke( logger.InnerLogger, targetEndpoint.DisplayName, envelope.ActualEndpointDisplayName, envelope.Headers.GetValue(DefaultMessageHeaders.MessageType), envelope.Headers.GetValue(DefaultMessageHeaders.MessageId), value1, value2, null); }
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 void LogSequenceStarted( this ISilverbackLogger logger, ISequence sequence) { if (!logger.IsEnabled(IntegrationLogEvents.SequenceStarted)) { return; } SequenceStarted( logger.InnerLogger, sequence.GetType().Name, sequence.SequenceId, null); }
public static void LogLowLevelTrace( this ISilverbackLogger logger, string message, Func <object[]> argumentsProvider) { if (!logger.IsEnabled(IntegrationLogEvents.LowLevelTracing)) { return; } logger.InnerLogger.Log( IntegrationLogEvents.LowLevelTracing.Level, IntegrationLogEvents.LowLevelTracing.EventId, message, argumentsProvider.Invoke()); }
public static void LogSequenceAbortingError( this ISilverbackLogger logger, ISequence sequence, Exception exception) { if (!logger.IsEnabled(IntegrationLogEvents.ErrorAbortingInboundSequence)) { return; } ErrorAbortingInboundSequence( logger.InnerLogger, sequence.GetType().Name, sequence.SequenceId, exception); }
public static void LogIncompleteSequenceAborted( this ISilverbackLogger logger, ISequence sequence) { if (!logger.IsEnabled(IntegrationLogEvents.IncompleteSequenceAborted)) { return; } IncompleteSequenceAborted( logger.InnerLogger, sequence.GetType().Name, sequence.SequenceId, sequence.Length, null); }
public static void LogConfluentConsumerError( this ISilverbackLogger logger, Error error, KafkaConsumer consumer) { if (!logger.IsEnabled(KafkaLogEvents.ConfluentConsumerError)) { return; } ConfluentConsumerError( logger.InnerLogger, GetErrorReason(error), (int)error.Code, consumer.Id, consumer.Endpoint.Name, null); }
public static void LogMqttClientError( this ISilverbackLogger logger, string?source, string message, object[]?parameters, Exception?exception) { if (!logger.IsEnabled(MqttLogEvents.MqttClientLogError)) { return; } MqttClientLogError( logger.InnerLogger, source ?? "-", FormatMqttClientMessage(message, parameters), exception); }
public static void LogConsumerRollbackError( this ISilverbackLogger logger, IConsumer consumer, IReadOnlyCollection <IBrokerMessageIdentifier> identifiers, Exception exception) { if (!logger.IsEnabled(IntegrationLogEvents.ConsumerRollbackError)) { return; } ConsumerRollbackError( logger.InnerLogger, consumer.Id, consumer.Endpoint.DisplayName, string.Join(", ", identifiers.Select(identifier => identifier.ToVerboseLogString())), exception); }
public static void LogSequenceAborted( this ISilverbackLogger logger, ISequence sequence, SequenceAbortReason reason) { if (!logger.IsEnabled(IntegrationLogEvents.SequenceProcessingAborted)) { return; } SequenceProcessingAborted( logger.InnerLogger, sequence.GetType().Name, sequence.SequenceId, sequence.Length, reason, null); }
public static void LogMessageAddedToSequence( this ISilverbackLogger logger, IRawInboundEnvelope envelope, ISequence sequence) { if (!logger.IsEnabled(IntegrationLogEvents.MessageAddedToSequence)) { return; } MessageAddedToSequence( logger.InnerLogger, envelope.Headers.GetValue(DefaultMessageHeaders.MessageId), sequence.GetType().Name, sequence.SequenceId, sequence.Length, null); }
public static void LogOffsetCommitError( this ISilverbackLogger logger, TopicPartitionOffsetError topicPartitionOffsetError, KafkaConsumer consumer) { if (!logger.IsEnabled(KafkaLogEvents.OffsetCommitError)) { return; } OffsetCommitError( logger.InnerLogger, topicPartitionOffsetError.Topic, topicPartitionOffsetError.Partition, topicPartitionOffsetError.Offset, GetErrorReason(topicPartitionOffsetError.Error), (int)topicPartitionOffsetError.Error.Code, consumer.Id, null); }
public void LogProcessing(ISilverbackLogger logger, IRawInboundEnvelope envelope) { if (!logger.IsEnabled(IntegrationLogEvents.ProcessingInboundMessage)) { return; } (string?value1, string?value2) = _logEnricher.GetAdditionalValues( envelope.Endpoint, envelope.Headers, envelope.BrokerMessageIdentifier); _processingInboundMessage.Invoke( logger.InnerLogger, envelope.ActualEndpointName, envelope.Headers.GetValue(DefaultMessageHeaders.MessageType), envelope.Headers.GetValue(DefaultMessageHeaders.MessageId), value1, value2, null); }
public void LogProduceError(ISilverbackLogger logger, IOutboundEnvelope envelope, Exception exception) { if (!logger.IsEnabled(IntegrationLogEvents.MessageProduced)) { return; } (string?value1, string?value2) = _logEnricher.GetAdditionalValues( envelope.Endpoint, envelope.Headers, null); _errorProducingMessage.Invoke( logger.InnerLogger, envelope.ActualEndpointDisplayName, envelope.Headers.GetValue(DefaultMessageHeaders.MessageType), envelope.Headers.GetValue(DefaultMessageHeaders.MessageId), value1, value2, exception); }
public void LogWrittenToOutbox(ISilverbackLogger logger, IOutboundEnvelope envelope) { if (!logger.IsEnabled(IntegrationLogEvents.MessageWrittenToOutbox)) { return; } (string?value1, string?value2) = _logEnricher.GetAdditionalValues( envelope.Endpoint, envelope.Headers, envelope.BrokerMessageIdentifier); _messageWrittenToOutbox.Invoke( logger.InnerLogger, envelope.ActualEndpointDisplayName, envelope.Headers.GetValue(DefaultMessageHeaders.MessageType), envelope.Headers.GetValue(DefaultMessageHeaders.MessageId), value1, value2, null); }
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()); }
public void LogErrorProducingOutboxStoredMessage( ISilverbackLogger logger, IOutboundEnvelope envelope, Exception exception) { if (!logger.IsEnabled(IntegrationLogEvents.ErrorProducingOutboxStoredMessage)) { return; } (string?value1, string?value2) = _logEnricher.GetAdditionalValues( envelope.Endpoint, envelope.Headers, envelope.BrokerMessageIdentifier); _errorProducingOutboxStoredMessage.Invoke( logger.InnerLogger, envelope.ActualEndpointName, envelope.Headers.GetValue(DefaultMessageHeaders.MessageType), envelope.Headers.GetValue(DefaultMessageHeaders.MessageId), value1, value2, exception); }
public void LogProcessingFatalError( ISilverbackLogger logger, IRawInboundEnvelope envelope, Exception exception) { if (!logger.IsEnabled(IntegrationLogEvents.ConsumerFatalError)) { return; } (string?value1, string?value2) = _logEnricher.GetAdditionalValues( envelope.Endpoint, envelope.Headers, envelope.BrokerMessageIdentifier); _consumerFatalError.Invoke( logger.InnerLogger, envelope.ActualEndpointName, envelope.Headers.GetValue(DefaultMessageHeaders.MessageType), envelope.Headers.GetValue(DefaultMessageHeaders.MessageId), value1, value2, exception); }
public void LogRollbackToSkipFailed( ISilverbackLogger logger, IRawInboundEnvelope envelope, Exception exception) { if (!logger.IsEnabled(IntegrationLogEvents.RollbackToSkipFailed)) { return; } (string?value1, string?value2) = _logEnricher.GetAdditionalValues( envelope.Endpoint, envelope.Headers, envelope.BrokerMessageIdentifier); _rollbackToSkipFailed.Invoke( logger.InnerLogger, envelope.ActualEndpointDisplayName, envelope.Headers.GetValue(DefaultMessageHeaders.MessageType), envelope.Headers.GetValue(DefaultMessageHeaders.MessageId), value1, value2, exception); }
public bool IsEnabled(LogLevel logLevel) => _logger.IsEnabled(logLevel);