Winify – Blame information for rev 67

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