blob: 57aea174f0cecec16af751a2f9d72e0c513776b1 (
plain)
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
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Tango.Logging
{
public class SimpleStringLogger : ILogger
{
private bool _enabled;
private bool _immidiate;
public bool Enabled { get => _enabled; set => _enabled = value; }
public bool Immediate { get => _immidiate; set => _immidiate = value; }
public List<LogCategory> Categories { get; set; }
public event EventHandler<LogItemBase> LogReceived;
public SimpleStringLogger()
{
Categories = new List<LogCategory>();
Categories.Add(LogCategory.Critical);
Categories.Add(LogCategory.Debug);
Categories.Add(LogCategory.Error);
Categories.Add(LogCategory.General);
Categories.Add(LogCategory.Warning);
Enabled = true;
}
public SimpleStringLogger(params LogCategory[] categories)
{
Categories = categories.ToList();
Enabled = true;
}
public void OnLog(LogItemBase log)
{
if (Categories.Contains(log.Category))
{
LogReceived?.Invoke(this, log);
}
}
}
}
|