BadScript 2
Loading...
Searching...
No Matches
BadLog.cs
Go to the documentation of this file.
2
7
11public struct BadLog : IEquatable<BadLog>
12{
16 public readonly string Message;
17
21 public readonly BadLogMask Mask;
22
26 public readonly BadLogType Type;
27
31 public readonly BadSourcePosition? Position;
32
40 public BadLog(string message,
41 BadLogMask? mask = null,
42 BadSourcePosition? position = null,
43 BadLogType type = BadLogType.Log)
44 {
45 Message = message;
46 Type = type;
47 Position = position;
48 Mask = mask ?? BadLogMask.Default;
49 }
50
56 public static implicit operator BadLog(string message)
57 {
58 return new BadLog(message);
59 }
60
65 public override string ToString()
66 {
67 return Position != null
68 ? $"[{Type}][{Mask}] {Message} at {Position.GetPositionInfo()}"
69 : $"[{Type}][{Mask}] {Message}";
70 }
71
77 public bool Equals(BadLog other)
78 {
79 return Message == other.Message && Mask.Equals(other.Mask) && Type == other.Type;
80 }
81
87 public override bool Equals(object? obj)
88 {
89 return obj is BadLog other && Equals(other);
90 }
91
92
97 public override int GetHashCode()
98 {
99 return BadHashCode.Combine(Message, Mask, (int)Type);
100 }
101
102 public static bool operator ==(BadLog left, BadLog right)
103 {
104 return left.Equals(right);
105 }
106
107 public static bool operator !=(BadLog left, BadLog right)
108 {
109 return !left.Equals(right);
110 }
111}
Describes a specific position inside a source file.
Implements a Mask for Log Messages.
Definition BadLogMask.cs:7
static readonly BadLogMask Default
Static Helper for the "Default" Mask.
Definition BadLogMask.cs:29
Implements Combination of HashCode Functions Taken from decompiled source of System....
Contains Logging system for the BadScript Runtime.
Definition BadLog.cs:6
Contains Utility Functions and Classes.
Definition BadEnum.cs:5
Represents a Log Message.
Definition BadLog.cs:12
readonly BadLogType Type
The Type of the message.
Definition BadLog.cs:26
bool Equals(BadLog other)
Returns true if the log is equal to the other log.
Definition BadLog.cs:77
readonly string Message
The Contents of the Message.
Definition BadLog.cs:16
override bool Equals(object? obj)
Returns true if the log is equal to the other object.
Definition BadLog.cs:87
BadLog(string message, BadLogMask? mask=null, BadSourcePosition? position=null, BadLogType type=BadLogType.Log)
Creates a new Log Message.
Definition BadLog.cs:40
static bool operator!=(BadLog left, BadLog right)
Definition BadLog.cs:107
static bool operator==(BadLog left, BadLog right)
Definition BadLog.cs:102
readonly BadLogMask Mask
The Mask of the message.
Definition BadLog.cs:21
override int GetHashCode()
Returns the Hash Code for this Instance.
Definition BadLog.cs:97
override string ToString()
Returns a string representation of the log.
Definition BadLog.cs:65
readonly? BadSourcePosition Position
The (optional) position of the message.
Definition BadLog.cs:31