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(
41 string message,
42 BadLogMask? mask = null,
43 BadSourcePosition? position = null,
44 BadLogType type = BadLogType.Log)
45 {
46 Message = message;
47 Type = type;
48 Position = position;
49 Mask = mask ?? BadLogMask.Default;
50 }
51
57 public static implicit operator BadLog(string message)
58 {
59 return new BadLog(message);
60 }
61
66 public override string ToString()
67 {
68 return Position != null ? $"[{Type}][{Mask}] {Message} at {Position.GetPositionInfo()}" : $"[{Type}][{Mask}] {Message}";
69 }
70
76 public bool Equals(BadLog other)
77 {
78 return Message == other.Message && Mask.Equals(other.Mask) && Type == other.Type;
79 }
80
86 public override bool Equals(object? obj)
87 {
88 return obj is BadLog other && Equals(other);
89 }
90
91
96 public override int GetHashCode()
97 {
98 return BadHashCode.Combine(Message, Mask, (int)Type);
99 }
100
101 public static bool operator ==(BadLog left, BadLog right)
102 {
103 return left.Equals(right);
104 }
105
106 public static bool operator !=(BadLog left, BadLog right)
107 {
108 return !left.Equals(right);
109 }
110}
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:34
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:76
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:86
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:106
static bool operator==(BadLog left, BadLog right)
Definition BadLog.cs:101
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:96
override string ToString()
Returns a string representation of the log.
Definition BadLog.cs:66
readonly? BadSourcePosition Position
The (optional) position of the message.
Definition BadLog.cs:31