-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathStackifyLogger.cs
More file actions
53 lines (46 loc) · 1.24 KB
/
StackifyLogger.cs
File metadata and controls
53 lines (46 loc) · 1.24 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using System;
using Microsoft.Extensions.Logging;
using StackifyLib.Models;
namespace StackifyLib.CoreLogger
{
public class StackifyLogger : Microsoft.Extensions.Logging.ILogger
{
public IDisposable BeginScope<TState>(TState state)
{
return null;
}
public bool IsEnabled(LogLevel logLevel)
{
return true;
}
public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter)
{
if (formatter == null)
{
throw new ArgumentNullException("formatter");
}
var message = formatter(state, exception);
if (string.IsNullOrEmpty(message))
{
return;
}
var msg = new LogMsg
{
Level = logLevel.ToString(),
Msg = message
};
StackifyLib.Logger.QueueLogObject(msg, exception);
}
public void Close()
{
try
{
StackifyLib.Logger.Shutdown();
}
catch (Exception)
{
// ignored
}
}
}
}