From 2b780a81471ca831cd74d7be35e6d1c1f6b61d73 Mon Sep 17 00:00:00 2001 From: Anas El Hajjaji Date: Wed, 4 Nov 2020 16:31:07 -0500 Subject: [PATCH] Make the class LokiHttpClient abstract to be used in appsettings.json --- src/Serilog.Sinks.Loki/DefaultLokiHttpClient.cs | 10 ++++++++++ src/Serilog.Sinks.Loki/LokiHttpClient.cs | 2 +- src/Serilog.Sinks.Loki/LokiSinkExtensions.cs | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 src/Serilog.Sinks.Loki/DefaultLokiHttpClient.cs diff --git a/src/Serilog.Sinks.Loki/DefaultLokiHttpClient.cs b/src/Serilog.Sinks.Loki/DefaultLokiHttpClient.cs new file mode 100644 index 0000000..e110c82 --- /dev/null +++ b/src/Serilog.Sinks.Loki/DefaultLokiHttpClient.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Serilog.Sinks.Loki +{ + public class DefaultLokiHttpClient : LokiHttpClient + { + } +} diff --git a/src/Serilog.Sinks.Loki/LokiHttpClient.cs b/src/Serilog.Sinks.Loki/LokiHttpClient.cs index 0700d25..4e7682e 100644 --- a/src/Serilog.Sinks.Loki/LokiHttpClient.cs +++ b/src/Serilog.Sinks.Loki/LokiHttpClient.cs @@ -7,7 +7,7 @@ namespace Serilog.Sinks.Loki { - public class LokiHttpClient : IHttpClient + public abstract class LokiHttpClient : IHttpClient { protected readonly HttpClient HttpClient; diff --git a/src/Serilog.Sinks.Loki/LokiSinkExtensions.cs b/src/Serilog.Sinks.Loki/LokiSinkExtensions.cs index 2baf2cb..cee9953 100644 --- a/src/Serilog.Sinks.Loki/LokiSinkExtensions.cs +++ b/src/Serilog.Sinks.Loki/LokiSinkExtensions.cs @@ -13,7 +13,7 @@ private static LoggerConfiguration LokiHttpImpl(this LoggerSinkConfiguration sin { var formatter = logLabelProvider != null ? new LokiBatchFormatter(logLabelProvider.GetLabels()) : new LokiBatchFormatter(); - var client = httpClient ?? new LokiHttpClient(); + var client = httpClient ?? new DefaultLokiHttpClient(); if (client is LokiHttpClient c) { c.SetAuthCredentials(credentials);