2023-07-16 17:33:15 +02:00
|
|
|
|
namespace Logging;
|
|
|
|
|
|
2023-09-19 15:59:52 +02:00
|
|
|
|
public readonly struct LogMessage
|
2023-07-16 17:33:15 +02:00
|
|
|
|
{
|
|
|
|
|
public DateTime logTime { get; }
|
|
|
|
|
public string caller { get; }
|
|
|
|
|
public string value { get; }
|
|
|
|
|
public string formattedMessage => ToString();
|
|
|
|
|
|
|
|
|
|
public LogMessage(DateTime messageTime, string caller, string value)
|
|
|
|
|
{
|
|
|
|
|
this.logTime = messageTime;
|
|
|
|
|
this.caller = caller;
|
|
|
|
|
this.value = value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string ToString()
|
|
|
|
|
{
|
|
|
|
|
string dateTimeString = $"{logTime.ToShortDateString()} {logTime.ToLongTimeString()}.{logTime.Millisecond,-3}";
|
|
|
|
|
string name = caller.Split(new char[] { '.', '+' }).Last();
|
|
|
|
|
return $"[{dateTimeString}] {name.Substring(0, name.Length >= 13 ? 13 : name.Length),13} | {value}";
|
|
|
|
|
}
|
|
|
|
|
}
|