<commit_before>﻿using NServiceBus.Configuration.AdvancedExtensibility;
using NServiceBus.Serilog;
using Serilog;

namespace NServiceBus
{
    /// <summary>
    /// Extensions to enable and configure Serilog Tracing.
    /// </summary>
    public static class SerilogTracingExtensions
    {
        /// <summary>
        /// Enable Serilog Tracing for this endpoint using <see cref="Log.Logger"/> as the logging target.
        /// </summary>
        public static SerilogTracingSettings EnableSerilogTracing(this EndpointConfiguration configuration)
        {
            return configuration.EnableSerilogTracing(Log.Logger);
        }

        /// <summary>
        /// Enable Serilog Tracing for this endpoint.
        /// </summary>
        public static SerilogTracingSettings EnableSerilogTracing(this EndpointConfiguration configuration, ILogger logger)
        {
            Guard.AgainstNull(configuration, nameof(configuration));
            Guard.AgainstNull(logger, nameof(logger));
            configuration.Recoverability().AddUnrecoverableException<ConfigurationException>();
            configuration.EnableFeature<TracingFeature>();
            var settings = configuration.GetSettings();
            var attachments = new SerilogTracingSettings(logger,configuration);
            settings.Set(attachments);
            return attachments;
        }

        /// <summary>
        /// Get the current <see cref="ILogger"/> for this context.
        /// </summary>
        public static ILogger Logger(this IPipelineContext context)
        {
            Guard.AgainstNull(context, nameof(context));
            var bag = context.Extensions;
            if (bag.TryGet("SerilogHandlerLogger", out ILogger logger))
            {
                return logger;
            }
            if (bag.TryGet(out logger))
            {
                return logger;

            }
            throw new ConfigurationException($"Expected to find a {nameof(ILogger)} in the pipeline context. It is possible a call to {nameof(SerilogTracingExtensions)}.{nameof(SerilogTracingExtensions.EnableSerilogTracing)} is missing.");
        }
    }
}<commit_msg>Update SerilogTracingExtensions.cs<commit_after>﻿using NServiceBus.Configuration.AdvancedExtensibility;
using NServiceBus.Serilog;
using Serilog;

namespace NServiceBus
{
    /// <summary>
    /// Extensions to enable and configure Serilog Tracing.
    /// </summary>
    public static class SerilogTracingExtensions
    {
        /// <summary>
        /// Enable Serilog Tracing for this endpoint using <see cref="Log.Logger"/> as the logging target.
        /// </summary>
        public static SerilogTracingSettings EnableSerilogTracing(this EndpointConfiguration configuration)
        {
            return configuration.EnableSerilogTracing(Log.Logger);
        }

        /// <summary>
        /// Enable Serilog Tracing for this endpoint.
        /// </summary>
        public static SerilogTracingSettings EnableSerilogTracing(this EndpointConfiguration configuration, ILogger logger)
        {
            Guard.AgainstNull(configuration, nameof(configuration));
            Guard.AgainstNull(logger, nameof(logger));
            configuration.Recoverability().AddUnrecoverableException<ConfigurationException>();
            configuration.EnableFeature<TracingFeature>();
            var settings = configuration.GetSettings();
            var attachments = new SerilogTracingSettings(logger,configuration);
            settings.Set(attachments);
            return attachments;
        }

        /// <summary>
        /// Get the current <see cref="ILogger"/> for this context.
        /// </summary>
        public static ILogger Logger(this IPipelineContext context)
        {
            Guard.AgainstNull(context, nameof(context));
            var bag = context.Extensions;
            if (bag.TryGet("SerilogHandlerLogger", out ILogger logger))
            {
                return logger;
            }
            if (bag.TryGet(out logger))
            {
                return logger;

            }
            throw new ConfigurationException($"Expected to find a {nameof(ILogger)} in the pipeline context. It is possible a call to {nameof(SerilogTracingExtensions)}.{nameof(EnableSerilogTracing)} is missing.");
        }
    }
}
{'fraction_non_alphanumeric': 0.09276437847866419, 'fraction_numerical': 0.0, 'mean_word_length': 2.3434108527131783, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1080826', 'n_tokens_mistral': 1072, 'n_tokens_neox': 1054, 'n_words': 259}