Winify – Blame information for rev 61

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  
9 namespace Winify
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 {
44 office 21 if (logEvent == null) throw new ArgumentNullException(nameof(logEvent));
43 office 22  
61 office 23 using var stringWriter = new StringWriter();
24 _textFormatter.Format(logEvent, stringWriter);
25 Events.Add(stringWriter.ToString());
43 office 26 }
27  
28 public void Clear()
29 {
30 Events.Clear();
31 }
32 }
33 }