using System.Text.Json.Serialization;

namespace RobotNet.MapShares.Models;

public class LoggerModel
{
    [JsonPropertyName("time")]
    public string? Time { get; set; }

    [JsonPropertyName("level")]
    public string? Level { get; set; }

    [JsonPropertyName("message")]
    public string? Message { get; set; }

    [JsonPropertyName("exception")]
    public string? Exception { get; set; }

    public string ColorClass => Level switch
    {
        "WARN" => "text-warning",
        "INFO" => "text-info",
        "DEBUG" => "text-success",
        "ERROR" => "text-danger",
        "FATAL" => "text-secondary",
        _ => "text-muted",
    };

    public string BackgroundClass => Level switch
    {
        "WARN" => "bg-warning text-dark",
        "INFO" => "bg-info text-dark",
        "DEBUG" => "bg-success text-white",
        "ERROR" => "bg-danger text-white",
        "FATAL" => "bg-secondary text-white",
        _ => "bg-dark text-white",
    };

    public bool HasException => !string.IsNullOrEmpty(Exception);
}
