| | | 1 | | using Microsoft.Extensions.DependencyInjection; |
| | | 2 | | using Microsoft.Extensions.Logging; |
| | | 3 | | |
| | | 4 | | namespace ArturRios.Logging.Adapter; |
| | | 5 | | |
| | | 6 | | /// <summary> |
| | | 7 | | /// Extension methods for configuring the custom logger with Microsoft.Extensions.Logging. |
| | | 8 | | /// </summary> |
| | | 9 | | public static class MicrosoftLoggerBuilderExtensions |
| | | 10 | | { |
| | | 11 | | /// <summary> |
| | | 12 | | /// Adds the custom logger provider to the logging builder. |
| | | 13 | | /// </summary> |
| | | 14 | | /// <param name="builder">The logging builder to configure.</param> |
| | | 15 | | /// <returns>The logging builder for method chaining.</returns> |
| | | 16 | | /// <exception cref="ArgumentNullException">Thrown when builder is null.</exception> |
| | | 17 | | public static ILoggingBuilder AddCustomLogger(this ILoggingBuilder builder) |
| | 9 | 18 | | { |
| | 9 | 19 | | ArgumentNullException.ThrowIfNull(builder); |
| | | 20 | | |
| | 8 | 21 | | builder.Services.AddSingleton<ILoggerProvider, MicrosoftLoggerProvider>(); |
| | | 22 | | |
| | 8 | 23 | | return builder; |
| | 8 | 24 | | } |
| | | 25 | | } |