mirror of
https://github.com/Caraxi/mare.client.git
synced 2025-12-15 07:34:14 +01:00
add events
This commit is contained in:
parent
532d88ed4c
commit
01ac0e476b
12 changed files with 448 additions and 3 deletions
45
MareSynchronos/Services/Events/Event.cs
Normal file
45
MareSynchronos/Services/Events/Event.cs
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
using MareSynchronos.API.Data;
|
||||
|
||||
namespace MareSynchronos.Services.Events;
|
||||
|
||||
public record Event
|
||||
{
|
||||
public DateTime EventTime { get; }
|
||||
public string UID { get; }
|
||||
public string Character { get; }
|
||||
public string EventSource { get; }
|
||||
public EventSeverity EventSeverity { get; }
|
||||
public string Message { get; }
|
||||
|
||||
public Event(string? Character, UserData UserData, string EventSource, EventSeverity EventSeverity, string Message)
|
||||
{
|
||||
EventTime = DateTime.Now;
|
||||
this.UID = UserData.AliasOrUID;
|
||||
this.Character = Character ?? string.Empty;
|
||||
this.EventSource = EventSource;
|
||||
this.EventSeverity = EventSeverity;
|
||||
this.Message = Message;
|
||||
}
|
||||
|
||||
public Event(UserData UserData, string EventSource, EventSeverity EventSeverity, string Message) : this(null, UserData, EventSource, EventSeverity, Message)
|
||||
{
|
||||
}
|
||||
|
||||
public Event(string EventSource, EventSeverity EventSeverity, string Message)
|
||||
: this(new UserData(string.Empty), EventSource, EventSeverity, Message)
|
||||
{
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
if (string.IsNullOrEmpty(UID))
|
||||
return $"{EventTime:HH:mm:ss.fff}\t[{EventSource}]{{{(int)EventSeverity}}}\t{Message}";
|
||||
else
|
||||
{
|
||||
if (string.IsNullOrEmpty(Character))
|
||||
return $"{EventTime:HH:mm:ss.fff}\t[{EventSource}]{{{(int)EventSeverity}}}\t<{UID}> {Message}";
|
||||
else
|
||||
return $"{EventTime:HH:mm:ss.fff}\t[{EventSource}]{{{(int)EventSeverity}}}\t<{UID}\\{Character}> {Message}";
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue