Skip to content

Commit 1165063

Browse files
authored
Merge pull request #52 from vtex/feature/remove_threshold
Feature/remove threshold
2 parents 0405632 + 6c65742 commit 1165063

14 files changed

+37
-69
lines changed

src/SampleWebAPI/appsettings.Development.json

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
"Logging": {
33
"IncludeScopes": false,
44
"LogLevel": {
5-
"Default": "Debug",
6-
"System": "Information",
7-
"Microsoft": "Information",
5+
"Default": "Trace",
6+
"System": "Debug",
7+
"Microsoft": "Debug",
88
"Splunk": "Trace"
99
}
1010
},
1111
"Splunk": {
1212
"HecConfiguration": {
13-
"BatchIntervalInMiliseconds": 5000,
13+
"BatchIntervalInMilliseconds": 5000,
1414
"BatchSizeCount": 10,
1515
"ChannelIdType": "None",
1616
"DefaultTimeoutInMiliseconds": 10000,
@@ -21,7 +21,6 @@
2121
"SocketConfiguration": {
2222
"HostName": "localhost",
2323
"Port": 4242
24-
},
25-
"Threshold": "Trace"
24+
}
2625
}
2726
}

src/SampleWebAPI/appsettings.json

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
11
{
22
"Logging": {
33
"IncludeScopes": false,
4-
"Debug": {
5-
"LogLevel": {
6-
"Default": "Warning"
7-
}
8-
},
9-
"Console": {
10-
"LogLevel": {
11-
"Default": "Warning",
12-
"Splunk": "Trace"
13-
}
14-
},
4+
"LogLevel": {
5+
"Default": "Information",
6+
"System": "Warning",
7+
"Microsoft": "Warning",
8+
"Splunk": "Trace"
9+
}
10+
},
1511
"Splunk": {
1612
"HecConfiguration": {
17-
"BatchIntervalInMiliseconds": 5000,
13+
"BatchIntervalInMilliseconds": 5000,
1814
"BatchSizeCount": 10,
1915
"ChannelIdType": "None",
2016
"DefaultTimeoutInMiliseconds": 10000,
@@ -25,8 +21,7 @@
2521
"SocketConfiguration": {
2622
"HostName": "localhost",
2723
"Port": 4242
28-
},
29-
"Threshold": "Trace"
24+
}
3025
}
3126
}
3227
}

src/SplunkLogger/BatchManager.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class BatchManager
1818
{
1919
readonly ConcurrentBag<object> events;
2020
readonly uint batchSizeCount;
21-
readonly uint batchIntervalInMiliseconds;
21+
readonly uint batchIntervalInMilliseconds;
2222
readonly Timer timer;
2323
readonly Action<List<object>> emitAction;
2424

@@ -29,17 +29,17 @@ public class BatchManager
2929
/// Initializes a new instance of the <see cref="T:Splunk.BatchManager"/> class.
3030
/// </summary>
3131
/// <param name="batchSizeCount">Batch size count.</param>
32-
/// <param name="batchIntervalInMiliseconds">Batch interval in miliseconds.</param>
32+
/// <param name="batchIntervalInMilliseconds">Batch interval in milliseconds.</param>
3333
/// <param name="emitAction">Emit action to be invoked at Emit process.</param>
34-
public BatchManager(uint batchSizeCount, uint batchIntervalInMiliseconds, Action<List<object>> emitAction)
34+
public BatchManager(uint batchSizeCount, uint batchIntervalInMilliseconds, Action<List<object>> emitAction)
3535
{
3636
events = new ConcurrentBag<object>();
3737
this.batchSizeCount = batchSizeCount;
38-
this.batchIntervalInMiliseconds = batchIntervalInMiliseconds;
38+
this.batchIntervalInMilliseconds = batchIntervalInMilliseconds;
3939

40-
if (batchIntervalInMiliseconds > 0)
40+
if (batchIntervalInMilliseconds > 0)
4141
{
42-
timer = new Timer(batchIntervalInMiliseconds);
42+
timer = new Timer(batchIntervalInMilliseconds);
4343
timer.AutoReset = false;
4444
timer.Enabled = true;
4545
timer.Elapsed += TimerTick;

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
}

0 commit comments

Comments
 (0)