diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index a73cc8b..cbe35f5 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -16,7 +16,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v1 with: - dotnet-version: 5.0.x + dotnet-version: 6.0.x - name: Restore dependencies run: dotnet restore - name: Build diff --git a/README.md b/README.md index 5b614ef..4eb80dc 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Once your Azure Event Hubs resource is configured in Azure, you can then add its { "Logging": { "AzureEventHubs": { - "Endpoint": "sb://example.servicebus.windows.net", + "FullyQualifiedNamespace": "example.servicebus.windows.net", "EntityPath": "my-hub", "SharedAccessKeyName": "my-key", "SharedAccessKey": "..." @@ -27,15 +27,15 @@ Once your Azure Event Hubs resource is configured in Azure, you can then add its } ``` -Add this logger provider to your logging builder, supplying a delegate that creates an `EventHubClient` to your specifications, for example: +Add this logger provider to your logging builder, supplying a delegate that creates an `EventHubProducerClient` to your specifications, for example: ```csharp var services = new ServiceCollection(); services.AddLogging(builder => builder.AddAzureEventHubs(options => options.TryGetConnectionString(out string connectionString) - ? EventHubClient.CreateFromConnectionString(connectionString) - : EventHubClient.CreateWithManagedServiceIdentity(options.Endpoint, options.EntityPath); + ? new EventHubProducerClient(connectionString) + : new EventHubProducerClient(options.FullyQualifiedNamespace, options.EntityPath, new DefaultAzureCredential()); )); ``` diff --git a/src/Runpath.Extensions.Logging.AzureEventHubs/AzureEventHubLoggerFactoryExtensions.cs b/src/Runpath.Extensions.Logging.AzureEventHubs/AzureEventHubLoggerFactoryExtensions.cs index e478660..0318593 100644 --- a/src/Runpath.Extensions.Logging.AzureEventHubs/AzureEventHubLoggerFactoryExtensions.cs +++ b/src/Runpath.Extensions.Logging.AzureEventHubs/AzureEventHubLoggerFactoryExtensions.cs @@ -1,63 +1,63 @@ -using System; -using Microsoft.Azure.EventHubs; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.DependencyInjection.Extensions; -using Microsoft.Extensions.Logging.Configuration; -using Runpath.Extensions.Logging.AzureEventHubs; - -// ReSharper disable once CheckNamespace -namespace Microsoft.Extensions.Logging -{ - public static class AzureEventHubLoggerFactoryExtensions - { - /// - /// Adds a AzureEventHubs logger named 'AzureEventHubs' to the factory. - /// - /// The to use. - /// - public static ILoggingBuilder AddAzureEventHubs(this ILoggingBuilder builder, - Func eventHubClientFactory) - { - if (builder is null) - { - throw new ArgumentNullException(nameof(builder)); - } - - builder.AddConfiguration(); - - builder.Services.TryAddSingleton(); - builder.Services.TryAddSingleton(); - builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton()); - builder.Services.RegisterProviderOptions(); - builder.Services.Configure(opts => opts.EventHubClientFactory = eventHubClientFactory); - - return builder; - } - - /// - /// Adds a AzureEventHubs logger named 'AzureEventHubs' to the factory. - /// - /// The to use. - /// - /// - public static ILoggingBuilder AddAzureEventHubs(this ILoggingBuilder builder, - Func eventHubClientFactory, - Action configure) - { - if (builder is null) - { - throw new ArgumentNullException(nameof(builder)); - } - - if (configure is null) - { - throw new ArgumentNullException(nameof(configure)); - } - - builder.AddAzureEventHubs(eventHubClientFactory); - builder.Services.Configure(configure); - - return builder; - } - } -} +using System; +using Azure.Messaging.EventHubs.Producer; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.DependencyInjection.Extensions; +using Microsoft.Extensions.Logging.Configuration; +using Runpath.Extensions.Logging.AzureEventHubs; + +// ReSharper disable once CheckNamespace +namespace Microsoft.Extensions.Logging +{ + public static class AzureEventHubLoggerFactoryExtensions + { + /// + /// Adds a AzureEventHubs logger named 'AzureEventHubs' to the factory. + /// + /// The to use. + /// + public static ILoggingBuilder AddAzureEventHubs(this ILoggingBuilder builder, + Func eventHubClientFactory) + { + if (builder is null) + { + throw new ArgumentNullException(nameof(builder)); + } + + builder.AddConfiguration(); + + builder.Services.TryAddSingleton(); + builder.Services.TryAddSingleton(); + builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton()); + builder.Services.RegisterProviderOptions(); + builder.Services.Configure(opts => opts.EventHubClientFactory = eventHubClientFactory); + + return builder; + } + + /// + /// Adds a AzureEventHubs logger named 'AzureEventHubs' to the factory. + /// + /// The to use. + /// + /// + public static ILoggingBuilder AddAzureEventHubs(this ILoggingBuilder builder, + Func eventHubClientFactory, + Action configure) + { + if (builder is null) + { + throw new ArgumentNullException(nameof(builder)); + } + + if (configure is null) + { + throw new ArgumentNullException(nameof(configure)); + } + + builder.AddAzureEventHubs(eventHubClientFactory); + builder.Services.Configure(configure); + + return builder; + } + } +} diff --git a/src/Runpath.Extensions.Logging.AzureEventHubs/AzureEventHubsLoggerOptions.cs b/src/Runpath.Extensions.Logging.AzureEventHubs/AzureEventHubsLoggerOptions.cs index a48fdce..6b2412c 100644 --- a/src/Runpath.Extensions.Logging.AzureEventHubs/AzureEventHubsLoggerOptions.cs +++ b/src/Runpath.Extensions.Logging.AzureEventHubs/AzureEventHubsLoggerOptions.cs @@ -1,34 +1,37 @@ -using System; -using System.Threading.Channels; -using Microsoft.Azure.EventHubs; - -namespace Runpath.Extensions.Logging.AzureEventHubs -{ - public class AzureEventHubsLoggerOptions - { - public Uri Endpoint { get; set; } - - public string EntityPath { get; set; } - - public string SharedAccessKeyName { get; set; } - - public string SharedAccessKey { get; set; } - - public bool IncludeScopes { get; set; } - - /// - /// The depth of the queue awaiting transmission to Azure Event Hubs. - /// Changing this value after app startup will have no effect. - /// - public int QueueDepth { get; set; } = 1024; - - /// - /// The mode used when queuing event data. Defaults to dropping the oldest messages in the - /// queue to avoid blocking. - /// Changing this value after app startup will have no effect. - /// - public BoundedChannelFullMode QueueMode { get; set; } = BoundedChannelFullMode.DropOldest; - - internal Func EventHubClientFactory { get; set; } - } -} +using System; +using System.Threading.Channels; +using Azure.Messaging.EventHubs.Producer; + +namespace Runpath.Extensions.Logging.AzureEventHubs +{ + public class AzureEventHubsLoggerOptions + { + public string FullyQualifiedNamespace { get; set; } + + [Obsolete("FullyQualifiedNamespace should be used instead. ")] + public Uri Endpoint { get; set; } + + public string EntityPath { get; set; } + + public string SharedAccessKeyName { get; set; } + + public string SharedAccessKey { get; set; } + + public bool IncludeScopes { get; set; } + + /// + /// The depth of the queue awaiting transmission to Azure Event Hubs. + /// Changing this value after app startup will have no effect. + /// + public int QueueDepth { get; set; } = 1024; + + /// + /// The mode used when queuing event data. Defaults to dropping the oldest messages in the + /// queue to avoid blocking. + /// Changing this value after app startup will have no effect. + /// + public BoundedChannelFullMode QueueMode { get; set; } = BoundedChannelFullMode.DropOldest; + + internal Func EventHubClientFactory { get; set; } + } +} diff --git a/src/Runpath.Extensions.Logging.AzureEventHubs/AzureEventHubsLoggerProvider.cs b/src/Runpath.Extensions.Logging.AzureEventHubs/AzureEventHubsLoggerProvider.cs index bb044ed..48f46f0 100644 --- a/src/Runpath.Extensions.Logging.AzureEventHubs/AzureEventHubsLoggerProvider.cs +++ b/src/Runpath.Extensions.Logging.AzureEventHubs/AzureEventHubsLoggerProvider.cs @@ -1,54 +1,53 @@ -using System; -using System.Collections.Concurrent; -using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Options; - -namespace Runpath.Extensions.Logging.AzureEventHubs -{ - [ProviderAlias("AzureEventHubs")] - public class AzureEventHubsLoggerProvider : ILoggerProvider, ISupportExternalScope - { - private readonly ConcurrentDictionary loggers; - private readonly IAzureEventHubsLoggerFormatter formatter; - private readonly IAzureEventHubsLoggerProcessor processor; - - private IDisposable optionsReloadToken; - private IExternalScopeProvider scopeProvider; - - public AzureEventHubsLoggerProvider(IAzureEventHubsLoggerFormatter formatter, IAzureEventHubsLoggerProcessor processor) - { - this.formatter = formatter; - this.processor = processor; - this.loggers = new ConcurrentDictionary(); - - SetScopeProvider(NullExternalScopeProvider.Instance); - } - - /// - public ILogger CreateLogger(string name) => this.loggers.GetOrAdd(name, - _ => new AzureEventHubsLogger(name, this.formatter, this.processor) - { - ScopeProvider = this.scopeProvider - }); - - /// - public void SetScopeProvider(IExternalScopeProvider scopeProvider) - { - this.scopeProvider = scopeProvider; - - this.formatter.ForEachScope = scopeProvider.ForEachScope; - - foreach (var logger in this.loggers) - { - logger.Value.ScopeProvider = this.scopeProvider; - } - } - - /// - public void Dispose() - { - this.optionsReloadToken?.Dispose(); - this.processor.Dispose(); - } - } -} +using System; +using System.Collections.Concurrent; +using Microsoft.Extensions.Logging; + +namespace Runpath.Extensions.Logging.AzureEventHubs +{ + [ProviderAlias("AzureEventHubs")] + public class AzureEventHubsLoggerProvider : ILoggerProvider, ISupportExternalScope + { + private readonly ConcurrentDictionary loggers; + private readonly IAzureEventHubsLoggerFormatter formatter; + private readonly IAzureEventHubsLoggerProcessor processor; + + private IDisposable optionsReloadToken; + private IExternalScopeProvider scopeProvider; + + public AzureEventHubsLoggerProvider(IAzureEventHubsLoggerFormatter formatter, IAzureEventHubsLoggerProcessor processor) + { + this.formatter = formatter; + this.processor = processor; + this.loggers = new ConcurrentDictionary(); + + SetScopeProvider(NullExternalScopeProvider.Instance); + } + + /// + public ILogger CreateLogger(string name) => this.loggers.GetOrAdd(name, + _ => new AzureEventHubsLogger(name, this.formatter, this.processor) + { + ScopeProvider = this.scopeProvider + }); + + /// + public void SetScopeProvider(IExternalScopeProvider scopeProvider) + { + this.scopeProvider = scopeProvider; + + this.formatter.ForEachScope = scopeProvider.ForEachScope; + + foreach (var logger in this.loggers) + { + logger.Value.ScopeProvider = this.scopeProvider; + } + } + + /// + public void Dispose() + { + this.optionsReloadToken?.Dispose(); + this.processor.Dispose(); + } + } +} diff --git a/src/Runpath.Extensions.Logging.AzureEventHubs/DefaultAzureEventHubsLoggerFormatter.cs b/src/Runpath.Extensions.Logging.AzureEventHubs/DefaultAzureEventHubsLoggerFormatter.cs index e8ca719..5421d53 100644 --- a/src/Runpath.Extensions.Logging.AzureEventHubs/DefaultAzureEventHubsLoggerFormatter.cs +++ b/src/Runpath.Extensions.Logging.AzureEventHubs/DefaultAzureEventHubsLoggerFormatter.cs @@ -1,45 +1,45 @@ -using System; -using System.Text; -using Microsoft.Azure.EventHubs; -using Microsoft.Extensions.Logging; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; - -namespace Runpath.Extensions.Logging.AzureEventHubs -{ - /// - /// Default implementation for . - /// - internal class DefaultAzureEventHubsLoggerFormatter : IAzureEventHubsLoggerFormatter - { - private static readonly Lazy JsonSerializerSettings = new Lazy(() => - new JsonSerializerSettings - { - DateFormatHandling = DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = DateTimeZoneHandling.Utc, - Error = (_, args) => args.ErrorContext.Handled = true, - NullValueHandling = NullValueHandling.Ignore, - ReferenceLoopHandling = ReferenceLoopHandling.Ignore, - Converters = { new StringEnumConverter() } - }); - - public ScopeCallback ForEachScope { get; set; } - - public EventData Format(string category, LogLevel logLevel, EventId eventId, TState state, Exception exception, Func formatter) - { - var model = new - { - Timestamp = DateTime.UtcNow, - Category = category, - LogLevel = logLevel, - EventId = eventId.Id, - Message = formatter(state, exception), - Exception = exception - }; - - string json = JsonConvert.SerializeObject(model, JsonSerializerSettings.Value); - - return new EventData(Encoding.UTF8.GetBytes(json)); - } - } -} +using System; +using System.Text; +using Azure.Messaging.EventHubs; +using Microsoft.Extensions.Logging; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; + +namespace Runpath.Extensions.Logging.AzureEventHubs +{ + /// + /// Default implementation for . + /// + internal class DefaultAzureEventHubsLoggerFormatter : IAzureEventHubsLoggerFormatter + { + private static readonly Lazy JsonSerializerSettings = new Lazy(() => + new JsonSerializerSettings + { + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + Error = (_, args) => args.ErrorContext.Handled = true, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Ignore, + Converters = { new StringEnumConverter() } + }); + + public ScopeCallback ForEachScope { get; set; } + + public EventData Format(string category, LogLevel logLevel, EventId eventId, TState state, Exception exception, Func formatter) + { + var model = new + { + Timestamp = DateTime.UtcNow, + Category = category, + LogLevel = logLevel, + EventId = eventId.Id, + Message = formatter(state, exception), + Exception = exception + }; + + string json = JsonConvert.SerializeObject(model, JsonSerializerSettings.Value); + + return new EventData(Encoding.UTF8.GetBytes(json)); + } + } +} diff --git a/src/Runpath.Extensions.Logging.AzureEventHubs/DefaultAzureEventHubsLoggerProcessor.cs b/src/Runpath.Extensions.Logging.AzureEventHubs/DefaultAzureEventHubsLoggerProcessor.cs index a87fa6a..73851fd 100644 --- a/src/Runpath.Extensions.Logging.AzureEventHubs/DefaultAzureEventHubsLoggerProcessor.cs +++ b/src/Runpath.Extensions.Logging.AzureEventHubs/DefaultAzureEventHubsLoggerProcessor.cs @@ -1,106 +1,107 @@ -using System; -using System.Threading; -using System.Threading.Channels; -using System.Threading.Tasks; -using Microsoft.Azure.EventHubs; -using Microsoft.Extensions.Options; - -namespace Runpath.Extensions.Logging.AzureEventHubs -{ - /// - /// Default implementation for . - /// - internal class DefaultAzureEventHubsLoggerProcessor : IAzureEventHubsLoggerProcessor - { - private readonly Channel channel; - - private IDisposable optionsReloadToken; - private EventHubClient eventHubClient; - - public DefaultAzureEventHubsLoggerProcessor(IOptionsMonitor options) - { - ReloadLoggerOptions(options.CurrentValue); - this.optionsReloadToken = options.OnChange(ReloadLoggerOptions); - - this.channel = Channel.CreateBounded(new BoundedChannelOptions(options.CurrentValue.QueueDepth) - { - FullMode = options.CurrentValue.QueueMode - }); - - Task.Factory.StartNew(ReadChannelAsync, - CancellationToken.None, - TaskCreationOptions.LongRunning | TaskCreationOptions.DenyChildAttach, - TaskScheduler.Default); - } - - private void ReloadLoggerOptions(AzureEventHubsLoggerOptions options) - { - this.eventHubClient = options.EventHubClientFactory?.Invoke(options); - } - - public void Process(EventData eventData) => this.channel.Writer.TryWrite(eventData); - - private async Task ReadChannelAsync() - { - while (await this.channel.Reader.WaitToReadAsync()) - { - // No client is available, so briefly pause before retrying. - if (this.eventHubClient is null) - { - await Task.Delay(TimeSpan.FromSeconds(1)).ConfigureAwait(false); - - continue; - } - - var eventDataBatch = this.eventHubClient.CreateBatch(); - - while (this.channel.Reader.TryRead(out var eventData)) - { - // Attempt to add the current event data to existing batch. - if (eventDataBatch.TryAdd(eventData)) - { - // There was space available, try to read more event data. - continue; - } - - // There was not enough space available, so send the current batch and create a - // new one. - await TrySendAsync(eventDataBatch).ConfigureAwait(false); - eventDataBatch = this.eventHubClient.CreateBatch(); - - // Attempt to add the current event data to new batch. - eventDataBatch.TryAdd(eventData); - } - - // No more event data is currently available, so send the current batch. - await TrySendAsync(eventDataBatch).ConfigureAwait(false); - } - } - - private async Task TrySendAsync(EventDataBatch eventDataBatch) - { - try - { - await this.eventHubClient.SendAsync(eventDataBatch).ConfigureAwait(false); - } - catch - { - // ignored - } - } - - public void Dispose() - { - try - { - this.channel.Writer.Complete(); - } - catch (ChannelClosedException) - { - // ignored - } - - this.optionsReloadToken?.Dispose(); - } - } -} +using System; +using System.Threading; +using System.Threading.Channels; +using System.Threading.Tasks; +using Azure.Messaging.EventHubs; +using Azure.Messaging.EventHubs.Producer; +using Microsoft.Extensions.Options; + +namespace Runpath.Extensions.Logging.AzureEventHubs +{ + /// + /// Default implementation for . + /// + internal class DefaultAzureEventHubsLoggerProcessor : IAzureEventHubsLoggerProcessor + { + private readonly Channel channel; + + private IDisposable optionsReloadToken; + private EventHubProducerClient eventHubClient; + + public DefaultAzureEventHubsLoggerProcessor(IOptionsMonitor options) + { + ReloadLoggerOptions(options.CurrentValue); + this.optionsReloadToken = options.OnChange(ReloadLoggerOptions); + + this.channel = Channel.CreateBounded(new BoundedChannelOptions(options.CurrentValue.QueueDepth) + { + FullMode = options.CurrentValue.QueueMode + }); + + Task.Factory.StartNew(ReadChannelAsync, + CancellationToken.None, + TaskCreationOptions.LongRunning | TaskCreationOptions.DenyChildAttach, + TaskScheduler.Default); + } + + private void ReloadLoggerOptions(AzureEventHubsLoggerOptions options) + { + this.eventHubClient = options.EventHubClientFactory?.Invoke(options); + } + + public void Process(EventData eventData) => this.channel.Writer.TryWrite(eventData); + + private async Task ReadChannelAsync() + { + while (await this.channel.Reader.WaitToReadAsync()) + { + // No client is available, so briefly pause before retrying. + if (this.eventHubClient is null) + { + await Task.Delay(TimeSpan.FromSeconds(1)).ConfigureAwait(false); + + continue; + } + + var eventDataBatch = await this.eventHubClient.CreateBatchAsync(); + + while (this.channel.Reader.TryRead(out var eventData)) + { + // Attempt to add the current event data to existing batch. + if (eventDataBatch.TryAdd(eventData)) + { + // There was space available, try to read more event data. + continue; + } + + // There was not enough space available, so send the current batch and create a + // new one. + await TrySendAsync(eventDataBatch).ConfigureAwait(false); + eventDataBatch = await this.eventHubClient.CreateBatchAsync(); + + // Attempt to add the current event data to new batch. + eventDataBatch.TryAdd(eventData); + } + + // No more event data is currently available, so send the current batch. + await TrySendAsync(eventDataBatch).ConfigureAwait(false); + } + } + + private async Task TrySendAsync(EventDataBatch eventDataBatch) + { + try + { + await this.eventHubClient.SendAsync(eventDataBatch).ConfigureAwait(false); + } + catch + { + // ignored + } + } + + public void Dispose() + { + try + { + this.channel.Writer.Complete(); + } + catch (ChannelClosedException) + { + // ignored + } + + this.optionsReloadToken?.Dispose(); + } + } +} diff --git a/src/Runpath.Extensions.Logging.AzureEventHubs/Extensions/AzureEventHubsLoggerOptionsExtensions.cs b/src/Runpath.Extensions.Logging.AzureEventHubs/Extensions/AzureEventHubsLoggerOptionsExtensions.cs index 6c91693..0bbbea9 100644 --- a/src/Runpath.Extensions.Logging.AzureEventHubs/Extensions/AzureEventHubsLoggerOptionsExtensions.cs +++ b/src/Runpath.Extensions.Logging.AzureEventHubs/Extensions/AzureEventHubsLoggerOptionsExtensions.cs @@ -1,31 +1,50 @@ -using Microsoft.Azure.EventHubs; - -// ReSharper disable once CheckNamespace -namespace Runpath.Extensions.Logging.AzureEventHubs -{ - public static class AzureEventHubsLoggerOptionsExtensions - { - /// - /// Attempts to build an Azure Event Hubs connections string from the component parts defined - /// in this instance. - /// - /// - /// - /// True, if all parts are present and valid. Otherwise, false. - public static bool TryGetConnectionString(this AzureEventHubsLoggerOptions options, out string connectionString) - { - try - { - var builder = new EventHubsConnectionStringBuilder(options.Endpoint, options.EntityPath, options.SharedAccessKeyName, options.SharedAccessKey); - - connectionString = builder.ToString(); - return true; - } - catch - { - connectionString = null; - return false; - } - } - } -} +// ReSharper disable once CheckNamespace +using System.Text; + +namespace Runpath.Extensions.Logging.AzureEventHubs +{ + public static class AzureEventHubsLoggerOptionsExtensions + { + private const char KeyValueSeparator = '='; + private const char KeyValuePairDelimiter = ';'; + + /// + /// Attempts to build an Azure Event Hubs connections string from the component parts defined + /// in this instance. + /// + /// + /// + /// True, if all parts are present and valid. Otherwise, false. + public static bool TryGetConnectionString(this AzureEventHubsLoggerOptions options, out string connectionString) + { + if (string.IsNullOrEmpty(options.SharedAccessKeyName) || string.IsNullOrEmpty(options.SharedAccessKey)) + { + connectionString = null; + return false; + } + + try + { + var builder = new StringBuilder(); + + if (string.IsNullOrEmpty(options.FullyQualifiedNamespace) && options.Endpoint != default) + { + options.FullyQualifiedNamespace = options.Endpoint.Host; + } + + builder.Append($"{nameof(options.FullyQualifiedNamespace)}{KeyValueSeparator}{options.FullyQualifiedNamespace}{KeyValuePairDelimiter}"); + builder.Append($"{nameof(options.EntityPath)}{KeyValueSeparator}{options.EntityPath}{KeyValuePairDelimiter}"); + builder.Append($"{nameof(options.SharedAccessKeyName)}{KeyValueSeparator}{options.SharedAccessKeyName}{KeyValuePairDelimiter}"); + builder.Append($"{nameof(options.SharedAccessKey)}{KeyValueSeparator}{options.SharedAccessKey}{KeyValuePairDelimiter}"); + + connectionString = builder.ToString(); + return true; + } + catch + { + connectionString = null; + return false; + } + } + } +} diff --git a/src/Runpath.Extensions.Logging.AzureEventHubs/IAzureEventHubsLoggerFormatter.cs b/src/Runpath.Extensions.Logging.AzureEventHubs/IAzureEventHubsLoggerFormatter.cs index 45999e0..27c6da3 100644 --- a/src/Runpath.Extensions.Logging.AzureEventHubs/IAzureEventHubsLoggerFormatter.cs +++ b/src/Runpath.Extensions.Logging.AzureEventHubs/IAzureEventHubsLoggerFormatter.cs @@ -1,37 +1,37 @@ -using System; -using Microsoft.Azure.EventHubs; -using Microsoft.Extensions.Logging; - -namespace Runpath.Extensions.Logging.AzureEventHubs -{ - /// - /// Exposes the ability to control the format of logger messages output by the Azure Event Hubs - /// logger provider. - /// - public interface IAzureEventHubsLoggerFormatter - { - /// - /// Executes a callback for each currently active scope object, in order of creation. - /// - ScopeCallback ForEachScope { get; set; } - - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - EventData Format(string category, LogLevel logLevel, EventId eventId, TState state, Exception exception, Func formatter); - } - - /// - /// Executes a callback for each currently active scope object, in order of creation. - /// - /// The callback to be executed for every scope object - /// The state object to be passed into the callback - public delegate void ScopeCallback(Action callback, object state); -} +using System; +using Azure.Messaging.EventHubs; +using Microsoft.Extensions.Logging; + +namespace Runpath.Extensions.Logging.AzureEventHubs +{ + /// + /// Exposes the ability to control the format of logger messages output by the Azure Event Hubs + /// logger provider. + /// + public interface IAzureEventHubsLoggerFormatter + { + /// + /// Executes a callback for each currently active scope object, in order of creation. + /// + ScopeCallback ForEachScope { get; set; } + + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + EventData Format(string category, LogLevel logLevel, EventId eventId, TState state, Exception exception, Func formatter); + } + + /// + /// Executes a callback for each currently active scope object, in order of creation. + /// + /// The callback to be executed for every scope object + /// The state object to be passed into the callback + public delegate void ScopeCallback(Action callback, object state); +} diff --git a/src/Runpath.Extensions.Logging.AzureEventHubs/IAzureEventHubsLoggerProcessor.cs b/src/Runpath.Extensions.Logging.AzureEventHubs/IAzureEventHubsLoggerProcessor.cs index 1b2c6a8..25263f8 100644 --- a/src/Runpath.Extensions.Logging.AzureEventHubs/IAzureEventHubsLoggerProcessor.cs +++ b/src/Runpath.Extensions.Logging.AzureEventHubs/IAzureEventHubsLoggerProcessor.cs @@ -1,14 +1,14 @@ -using System; -using Microsoft.Azure.EventHubs; - -namespace Runpath.Extensions.Logging.AzureEventHubs -{ - /// - /// Exposes the ability to process Azure Event Hub instances output by - /// the Azure Event Hubs logger provider. - /// - public interface IAzureEventHubsLoggerProcessor : IDisposable - { - void Process(EventData eventData); - } -} +using System; +using Azure.Messaging.EventHubs; + +namespace Runpath.Extensions.Logging.AzureEventHubs +{ + /// + /// Exposes the ability to process Azure Event Hub instances output by + /// the Azure Event Hubs logger provider. + /// + public interface IAzureEventHubsLoggerProcessor : IDisposable + { + void Process(EventData eventData); + } +} diff --git a/src/Runpath.Extensions.Logging.AzureEventHubs/Runpath.Extensions.Logging.AzureEventHubs.csproj b/src/Runpath.Extensions.Logging.AzureEventHubs/Runpath.Extensions.Logging.AzureEventHubs.csproj index c9e16df..f6cb56d 100644 --- a/src/Runpath.Extensions.Logging.AzureEventHubs/Runpath.Extensions.Logging.AzureEventHubs.csproj +++ b/src/Runpath.Extensions.Logging.AzureEventHubs/Runpath.Extensions.Logging.AzureEventHubs.csproj @@ -1,41 +1,41 @@ - - - - netstandard2.0 - 7.2 - true - Runpath Digital - Runpath Digital - Azure Event Hubs logger provider implementation for Microsoft.Extensions.Logging. - 1.2.0 - true - logging azure event hubs - https://github.com/Runpath/Runpath.Extensions.Logging.AzureEventHubs - https://github.com/Runpath/Runpath.Extensions.Logging.AzureEventHubs - git - Apache-2.0 - true - https://www.runpath.com/assets/images/dist/favicons/ms-icon-310x310.png - © Experian plc. All rights reserved. - - - - - - - - - <_Parameter1>Runpath.Extensions.Logging.AzureEventHubs.Tests - - - - - - - - - - - - + + + + netstandard2.0 + 7.2 + true + Runpath Digital + Runpath Digital + Azure Event Hubs logger provider implementation for Microsoft.Extensions.Logging. + 2.0.0-preview1 + true + logging azure event hubs + https://github.com/Runpath/Runpath.Extensions.Logging.AzureEventHubs + https://github.com/Runpath/Runpath.Extensions.Logging.AzureEventHubs + git + Apache-2.0 + true + https://www.runpath.com/assets/images/dist/favicons/ms-icon-310x310.png + © Experian plc. All rights reserved. + + + + + + + + + <_Parameter1>Runpath.Extensions.Logging.AzureEventHubs.Tests + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/Runpath.Extensions.Logging.AzureEventHubs.Tests/Runpath.Extensions.Logging.AzureEventHubs.Tests.csproj b/tests/Runpath.Extensions.Logging.AzureEventHubs.Tests/Runpath.Extensions.Logging.AzureEventHubs.Tests.csproj index adee256..e31aef3 100644 --- a/tests/Runpath.Extensions.Logging.AzureEventHubs.Tests/Runpath.Extensions.Logging.AzureEventHubs.Tests.csproj +++ b/tests/Runpath.Extensions.Logging.AzureEventHubs.Tests/Runpath.Extensions.Logging.AzureEventHubs.Tests.csproj @@ -1,21 +1,24 @@ - - - - netcoreapp2.1 - - false - - - - - - - - - - - - - - - + + + + net6 + + false + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + +