-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathLogicmonitorSink.cs
38 lines (31 loc) · 1.09 KB
/
LogicmonitorSink.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using System;
using Serilog.Events;
using LogicMonitor.DataSDK.Api;
using LogicMonitor.DataSDK.Model;
using LogicMonitor.DataSDK;
using conf = LogicMonitor.DataSDK.Configuration;
using Serilog.Core;
namespace Serilog.Sinks.LogicMonitor
{
public class LogicmonitorSink : ILogEventSink
{
Logs Logs;
conf Configuration;
Resource Resource;
public LogicmonitorSink(conf conf = null, Resource resource = null, bool batch = true, int interval = 10)
{
Configuration = conf ??= new conf();
ApiClient apiClient = new ApiClient(Configuration);
Resource = resource ??= new Resource();
Logs = new Logs(batch: batch, interval: interval, apiClient: apiClient);
}
/// <summary>
/// Emit a batch of log events to LogicMonitor platform.
/// </summary>
/// <param name="events">The events to emit.</param>
public void Emit(LogEvent logEvent)
{
var response = Logs.SendLogs(message: logEvent.MessageTemplate.Text, resource: Resource);
}
}
}