Skip to content

Commit cfcfc6e

Browse files
committed
Removed unnecessary threshold property
#50
1 parent 0405632 commit cfcfc6e

11 files changed

+17
-43
lines changed

src/SplunkLogger/Configurations/SplunkLoggerConfiguration.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using Microsoft.Extensions.Logging;
2-
1+

32
namespace Splunk.Configurations
43
{
54
/// <summary>
@@ -16,10 +15,5 @@ public class SplunkLoggerConfiguration
1615
/// Gets or sets the socket configuration.
1716
/// </summary>
1817
public SocketConfiguration SocketConfiguration { get; set; }
19-
20-
/// <summary>
21-
/// Gets or sets the threshold.
22-
/// </summary>
23-
public LogLevel Threshold { get; set; }
2418
}
2519
}

src/SplunkLogger/Loggers/BaseLogger.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,15 @@ public abstract class BaseLogger : ILogger
1111
protected readonly ILoggerFormatter loggerFormatter;
1212

1313
readonly string categoryName;
14-
readonly LogLevel threshold;
1514

1615
/// <summary>
1716
/// Initializes a new instance of the <see cref="T:Splunk.Loggers.BaseLogger"/> class.
1817
/// </summary>
1918
/// <param name="categoryName">Category name.</param>
20-
/// <param name="threshold">Threshold.</param>
2119
/// <param name="loggerFormatter">Formatter instance.</param>
22-
public BaseLogger(string categoryName, LogLevel threshold, ILoggerFormatter loggerFormatter)
20+
public BaseLogger(string categoryName, ILoggerFormatter loggerFormatter)
2321
{
2422
this.categoryName = categoryName;
25-
this.threshold = threshold;
2623
this.loggerFormatter = loggerFormatter;
2724
}
2825

@@ -33,7 +30,7 @@ public BaseLogger(string categoryName, LogLevel threshold, ILoggerFormatter logg
3330
/// <param name="logLevel">.Net Core Log level.</param>
3431
public bool IsEnabled(LogLevel logLevel)
3532
{
36-
return (int)logLevel >= (int)threshold;
33+
return true;
3734
}
3835

3936
/// <summary>

src/SplunkLogger/Loggers/HECBaseLogger.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,11 @@ public abstract class HECBaseLogger : BaseLogger
1616
/// Initializes a new instance of the <see cref="T:Splunk.Loggers.HECBaseLogger"/> class.
1717
/// </summary>
1818
/// <param name="categoryName">Category name.</param>
19-
/// <param name="threshold">Threshold.</param>
2019
/// <param name="httpClient">Http client.</param>
2120
/// <param name="batchManager">Batch manager.</param>
2221
/// <param name="loggerFormatter">Formatter instance.</param>
23-
public HECBaseLogger(string categoryName, LogLevel threshold, HttpClient httpClient, BatchManager batchManager, ILoggerFormatter loggerFormatter)
24-
: base(categoryName, threshold, loggerFormatter)
22+
public HECBaseLogger(string categoryName, HttpClient httpClient, BatchManager batchManager, ILoggerFormatter loggerFormatter)
23+
: base(categoryName, loggerFormatter)
2524
{
2625
this.httpClient = httpClient;
2726
this.batchManager = batchManager;

src/SplunkLogger/Loggers/HECJsonLogger.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,11 @@ public class HECJsonLogger : HECBaseLogger, ILogger
1414
/// Initializes a new instance of the <see cref="T:Splunk.Loggers.HECJsonLogger"/> class.
1515
/// </summary>
1616
/// <param name="categoryName">Category name.</param>
17-
/// <param name="threshold">Threshold.</param>
1817
/// <param name="httpClient">Http client.</param>
1918
/// <param name="batchManager">Batch manager.</param>
2019
/// <param name="loggerFormatter">Formatter instance.</param>
21-
public HECJsonLogger(string categoryName, LogLevel threshold, HttpClient httpClient, BatchManager batchManager, ILoggerFormatter loggerFormatter)
22-
: base(categoryName, threshold, httpClient, batchManager, loggerFormatter)
20+
public HECJsonLogger(string categoryName, HttpClient httpClient, BatchManager batchManager, ILoggerFormatter loggerFormatter)
21+
: base(categoryName, httpClient, batchManager, loggerFormatter)
2322
{
2423
}
2524

src/SplunkLogger/Loggers/HECRawLogger.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,11 @@ public class HECRawLogger : HECBaseLogger, ILogger
1313
/// Initializes a new instance of the <see cref="T:Splunk.Loggers.HECRawLogger"/> class.
1414
/// </summary>
1515
/// <param name="categoryName">Category name.</param>
16-
/// <param name="threshold">Threshold.</param>
1716
/// <param name="httpClient">Http client.</param>
1817
/// <param name="batchManager">Batch manager.</param>
1918
/// <param name="loggerFormatter">Formatter instance.</param>
20-
public HECRawLogger(string categoryName, LogLevel threshold, HttpClient httpClient, BatchManager batchManager, ILoggerFormatter loggerFormatter)
21-
: base(categoryName, threshold, httpClient, batchManager, loggerFormatter)
19+
public HECRawLogger(string categoryName, HttpClient httpClient, BatchManager batchManager, ILoggerFormatter loggerFormatter)
20+
: base(categoryName, httpClient, batchManager, loggerFormatter)
2221
{
2322
}
2423

src/SplunkLogger/Loggers/TcpLogger.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,10 @@ public class TcpLogger : BaseLogger, ILogger
1616
/// Initializes a new instance of the <see cref="T:Splunk.Loggers.TcpLogger"/> class.
1717
/// </summary>
1818
/// <param name="categoryName">Category name.</param>
19-
/// <param name="threshold">Threshold.</param>
2019
/// <param name="tcpClient">Tcp client.</param>
2120
/// <param name="loggerFormatter">Formatter instance.</param>
22-
public TcpLogger(string categoryName, LogLevel threshold, TcpClient tcpClient, ILoggerFormatter loggerFormatter)
23-
: base(categoryName, threshold, loggerFormatter)
21+
public TcpLogger(string categoryName, TcpClient tcpClient, ILoggerFormatter loggerFormatter)
22+
: base(categoryName, loggerFormatter)
2423
{
2524
this.tcpClient = tcpClient;
2625
}

src/SplunkLogger/Loggers/UdpLogger.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,10 @@ public class UdpLogger : BaseLogger, ILogger
1616
/// Initializes a new instance of the <see cref="T:Splunk.Loggers.UdpLogger"/> class.
1717
/// </summary>
1818
/// <param name="categoryName">Category name.</param>
19-
/// <param name="threshold">Threshold.</param>
2019
/// <param name="udpClient">UDP client.</param>
2120
/// <param name="loggerFormatter">Formatter instance.</param>
22-
public UdpLogger(string categoryName, LogLevel threshold, UdpClient udpClient, ILoggerFormatter loggerFormatter)
23-
: base(categoryName, threshold, loggerFormatter)
21+
public UdpLogger(string categoryName, UdpClient udpClient, ILoggerFormatter loggerFormatter)
22+
: base(categoryName, loggerFormatter)
2423
{
2524
this.udpClient = udpClient;
2625
}

src/SplunkLogger/Providers/SplunkHECJsonLoggerProvider.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ namespace Splunk.Providers
1616
public class SplunkHECJsonLoggerProvider : SplunkHECBaseProvider, ILoggerProvider
1717
{
1818
readonly BatchManager batchController;
19-
readonly LogLevel threshold;
2019
readonly ILoggerFormatter loggerFormatter;
2120
readonly ConcurrentDictionary<string, ILogger> loggers;
2221

@@ -29,8 +28,6 @@ public SplunkHECJsonLoggerProvider(SplunkLoggerConfiguration configuration, ILog
2928
{
3029
loggers = new ConcurrentDictionary<string, ILogger>();
3130

32-
threshold = configuration.Threshold;
33-
3431
this.loggerFormatter = loggerFormatter;
3532

3633
SetupHttpClient(configuration, "event");
@@ -69,7 +66,7 @@ public override void Dispose()
6966
/// <param name="categoryName">Category name.</param>
7067
public override ILogger CreateLoggerInstance(string categoryName)
7168
{
72-
return new HECJsonLogger(categoryName, threshold, httpClient, batchController, loggerFormatter);
69+
return new HECJsonLogger(categoryName, httpClient, batchController, loggerFormatter);
7370
}
7471

7572
/// <summary>

src/SplunkLogger/Providers/SplunkHECRawLoggerProvider.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ namespace Splunk.Providers
1515
public class SplunkHECRawLoggerProvider : SplunkHECBaseProvider, ILoggerProvider
1616
{
1717
readonly BatchManager batchManager;
18-
readonly LogLevel threshold;
1918
readonly ILoggerFormatter loggerFormatter;
2019
readonly ConcurrentDictionary<string, ILogger> loggers;
2120

@@ -28,8 +27,6 @@ public SplunkHECRawLoggerProvider(SplunkLoggerConfiguration configuration, ILogg
2827
{
2928
loggers = new ConcurrentDictionary<string, ILogger>();
3029

31-
threshold = configuration.Threshold;
32-
3330
this.loggerFormatter = loggerFormatter;
3431

3532
SetupHttpClient(configuration, "raw");
@@ -68,7 +65,7 @@ public override void Dispose()
6865
/// <param name="categoryName">Category name.</param>
6966
public override ILogger CreateLoggerInstance(string categoryName)
7067
{
71-
return new HECRawLogger(categoryName, threshold, httpClient, batchManager, loggerFormatter);
68+
return new HECRawLogger(categoryName, httpClient, batchManager, loggerFormatter);
7269
}
7370

7471
/// <summary>

src/SplunkLogger/Providers/SplunkTcpLoggerProvider.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ namespace Splunk.Providers
1111
/// </summary>
1212
public class SplunkTcpLoggerProvider : ILoggerProvider
1313
{
14-
readonly LogLevel threshold;
1514
readonly ILoggerFormatter loggerFormatter;
1615
readonly ConcurrentDictionary<string, ILogger> loggers;
1716
readonly TcpClient tcpClient;
@@ -25,8 +24,6 @@ public SplunkTcpLoggerProvider(SplunkLoggerConfiguration configuration, ILoggerF
2524
{
2625
loggers = new ConcurrentDictionary<string, ILogger>();
2726

28-
threshold = configuration.Threshold;
29-
3027
this.loggerFormatter = loggerFormatter;
3128

3229
tcpClient = new TcpClient(configuration.SocketConfiguration.HostName, configuration.SocketConfiguration.Port);
@@ -36,7 +33,7 @@ public SplunkTcpLoggerProvider(SplunkLoggerConfiguration configuration, ILoggerF
3633

3734
ILogger CreateLoggerInstance(string categoryName)
3835
{
39-
return new TcpLogger(categoryName, threshold, tcpClient, loggerFormatter);
36+
return new TcpLogger(categoryName, tcpClient, loggerFormatter);
4037
}
4138

4239
/// <summary>

0 commit comments

Comments
 (0)