BadScript 2
Loading...
Searching...
No Matches
BadLogWriter.cs
Go to the documentation of this file.
1
4
6
10public abstract class BadLogWriter : IDisposable
11{
12 public bool IsActive { get; private set; }
13
17 public virtual void Dispose()
18 {
19 Unregister();
20 }
21
26 protected abstract void Write(BadLog log);
27
32 private void InnerWrite(BadLog log)
33 {
34 if (BadLogWriterSettings.Instance.Mask.Contains(log.Mask))
35 {
36 Write(log);
37 }
38 }
39
43 public void Register()
44 {
45 if (IsActive)
46 {
47 return;
48 }
49
50 BadLogger.OnLog += InnerWrite;
51 IsActive = true;
52 }
53
54
58 public void Unregister()
59 {
60 if (!IsActive)
61 {
62 return;
63 }
64
65 BadLogger.OnLog -= InnerWrite;
66 IsActive = false;
67 }
68}
void InnerWrite(BadLog log)
Inner Write Log Method makes sure the log is only written if the Mask Settings contain the log mask.
void Unregister()
Unregisters the Log Writer from the Log System.
virtual void Dispose()
Implements the IDisposable interface.
void Write(BadLog log)
Writes a log message to the log writer.
void Register()
Registers the Log Writer to the Log System.
static T Instance
Returns the Instance of the Settings Provider.
Contains Writer Implementations for the BadScript Logging System.
Represents a Log Message.
Definition BadLog.cs:12
readonly BadLogMask Mask
The Mask of the message.
Definition BadLog.cs:21