using AyCode.Core.Enums;
using AyCode.Core.Loggers;
using MessagePack;

namespace AyCode.Entities.LogItems;

[MessagePackObject]
public class AcLogItemClient : IAcLogItemClient
{
    [Key(5)] public DateTime TimeStampUtc { get; set; }

    [Key(15)] public AppType AppType { get; set; }
    [Key(20)] public LogLevel LogLevel { get; set; }
    [Key(25)] public int ThreadId { get; set; } = Environment.CurrentManagedThreadId;
    [Key(30)] public string? CategoryName { get; set; }
    [Key(35)] public string? CallerName { get; set; }
    [Key(40)] public string? Text { get; set; }
    [Key(45)] public string? ErrorType { get; set; }
    [Key(50)] public string? Exception { get; set; }

    public override string? ToString() => Text ?? base.ToString();

    //public string ErrorText() => string.IsNullOrWhiteSpace(ErrorType) ? string.Empty : $"{AcEnv.NL}[{ErrorType.ToUpper()}]: {Exception}";

    //public string ToMinimalText() => $"{"[" + CategoryName + "->" + CallerName + "]"}  -  {"[" + ThreadId + "]", 5} {Text}{ErrorText()}";

    //public string ToNormalText() 
    //    => $"{"[" + LogLevel + "]",-9} {"[" + CategoryName + "->" + CallerName + "]"}  -  {"[" + ThreadId + "]", 5} {Text}{ErrorText()}";

    //public string ToDetailText()
    //    => $"[{TimeStampUtc.ToLocalTime():HH:mm:ss.fff}] {"[" + LogLevel + "]",-9} {"[" + CategoryName + "->" + CallerName + "]", -55}  {"[" + ThreadId + "]", 5} {Text}{ErrorText()}";

    //public string ToDiagnosticText()
    //    => $"[{TimeStampUtc.ToLocalTime():HH:mm:ss.fff}] [{AppType.ToString()[0]}] {"[" + LogLevel + "]",-9} {"[" + CategoryName + "->" + CallerName + "]", -54}  {"[" + ThreadId + "]", 5} {Text}{ErrorText()}";
}