Skip to content

Commit d386dc6

Browse files
committed
Implemented JSON Raw logger class
#5
1 parent dc017ce commit d386dc6

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using System;
2+
using System.Net.Http;
3+
using Microsoft.Extensions.Logging;
4+
5+
namespace Splunk.Loggers
6+
{
7+
public class HECRawLogger : HECBaseLogger, ILogger
8+
{
9+
public HECRawLogger(string categoryName, LogLevel threshold, HttpClient httpClient, BatchManager batchManager, ILoggerFormatter loggerFormatter)
10+
: base(categoryName, threshold, httpClient, batchManager, loggerFormatter)
11+
{
12+
}
13+
14+
public void Log<T>(LogLevel logLevel, EventId eventId, T state, Exception exception, Func<T, Exception, string> formatter)
15+
{
16+
string formatedMessage = string.Empty;
17+
if (loggerFormatter != null)
18+
formatedMessage = loggerFormatter.Format(logLevel, eventId, state, exception);
19+
else if (formatter != null)
20+
formatedMessage = formatter(state, exception);
21+
22+
if (!string.IsNullOrWhiteSpace(formatedMessage))
23+
batchManager.Add(formatedMessage);
24+
}
25+
}
26+
}

0 commit comments

Comments
 (0)