forked from Misaki/GhostEngine
Added new RHI abstraction layer;
Added new console debug page to UnitTest;
This commit is contained in:
42
Ghost.UnitTest/Models/LogItem.cs
Normal file
42
Ghost.UnitTest/Models/LogItem.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using System;
|
||||
|
||||
namespace Ghost.UnitTest.Models;
|
||||
|
||||
public enum LogLevel
|
||||
{
|
||||
Info,
|
||||
Warning,
|
||||
Error,
|
||||
Debug
|
||||
}
|
||||
|
||||
internal struct LogItem
|
||||
{
|
||||
public LogLevel Level { get; init; }
|
||||
public string Message { get; init; }
|
||||
public DateTime Timestamp { get; init; }
|
||||
public string? StackTrace { get; init; }
|
||||
|
||||
public LogItem(LogLevel level, string message, string? stackTrace = null)
|
||||
{
|
||||
Level = level;
|
||||
Message = message;
|
||||
StackTrace = stackTrace;
|
||||
Timestamp = DateTime.Now;
|
||||
}
|
||||
|
||||
public override readonly string ToString()
|
||||
{
|
||||
return $"{Timestamp:HH:mm:ss.fff} [{Level}] {Message}";
|
||||
}
|
||||
|
||||
public readonly string ToStringWithStackTrace()
|
||||
{
|
||||
if (string.IsNullOrEmpty(StackTrace))
|
||||
{
|
||||
return ToString();
|
||||
}
|
||||
|
||||
return $"{ToString()}\n{StackTrace}";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user