Winify – Diff between revs 61 and 67
?pathlinks?
Rev 61 | Rev 67 | |||
---|---|---|---|---|
1 | using System; |
1 | using System; |
|
2 | using System.Collections.ObjectModel; |
2 | using System.Collections.ObjectModel; |
|
3 | using System.IO; |
3 | using System.IO; |
|
4 | using Serilog.Core; |
4 | using Serilog.Core; |
|
5 | using Serilog.Events; |
5 | using Serilog.Events; |
|
6 | using Serilog.Formatting; |
6 | using Serilog.Formatting; |
|
7 | using Serilog.Formatting.Display; |
7 | using Serilog.Formatting.Display; |
|
8 | |
8 | |
|
9 | namespace Winify |
9 | namespace Winify.Utilities |
|
10 | { |
10 | { |
|
11 | public class LogMemorySink : ILogEventSink |
11 | public class LogMemorySink : ILogEventSink |
|
12 | { |
12 | { |
|
13 | private readonly ITextFormatter _textFormatter = |
13 | private readonly ITextFormatter _textFormatter = |
|
14 | new MessageTemplateTextFormatter( |
14 | new MessageTemplateTextFormatter( |
|
15 | "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {Message:l}{NewLine}{Exception}"); |
15 | "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {Message:l}{NewLine}{Exception}"); |
|
16 | |
16 | |
|
17 | public ObservableCollection<string> Events { get; } = new ObservableCollection<string>(); |
17 | public ObservableCollection<string> Events { get; } = new ObservableCollection<string>(); |
|
18 | |
18 | |
|
19 | public void Emit(LogEvent logEvent) |
19 | public void Emit(LogEvent logEvent) |
|
20 | { |
20 | { |
|
- | 21 | if (logEvent == null) |
||
- | 22 | { |
||
21 | if (logEvent == null) throw new ArgumentNullException(nameof(logEvent)); |
23 | throw new ArgumentNullException(nameof(logEvent)); |
|
- | 24 | } |
||
22 | |
25 | |
|
23 | using var stringWriter = new StringWriter(); |
26 | using var stringWriter = new StringWriter(); |
|
24 | _textFormatter.Format(logEvent, stringWriter); |
27 | _textFormatter.Format(logEvent, stringWriter); |
|
25 | Events.Add(stringWriter.ToString()); |
28 | Events.Add(stringWriter.ToString()); |
|
26 | } |
29 | } |
|
27 | |
30 | |
|
28 | public void Clear() |
31 | public void Clear() |
|
29 | { |
32 | { |
|
30 | Events.Clear(); |
33 | Events.Clear(); |
|
31 | } |
34 | } |
|
32 | } |
35 | } |
|
33 | } |
36 | } |
|
34 | |
37 | |
|
35 |
|
38 |
|
|
36 | |
39 | |
|
37 | |
40 | |
|
38 | |
41 | |