using Avalonia.Media;
using Serilog.Events;

namespace Predictalytics.Shell.ViewModels;

/// <summary>Eine Zeile der Terminalanzeige samt Einfaerbung nach Loglevel.</summary>
public sealed class LogLine
{
    public string Text { get; }
    public IBrush Foreground { get; }

    public LogLine(string text, LogEventLevel level)
    {
        Text = text;
        Foreground = BrushFor(level);
    }

    // Farbschema unveraendert aus der WinForms-Fassung uebernommen.
    private static IBrush BrushFor(LogEventLevel level) => level switch
    {
        LogEventLevel.Error or LogEventLevel.Fatal => new SolidColorBrush(Color.FromRgb(255, 82, 82)),
        LogEventLevel.Warning => new SolidColorBrush(Color.FromRgb(255, 193, 7)),
        LogEventLevel.Debug or LogEventLevel.Verbose => new SolidColorBrush(Color.FromRgb(158, 158, 158)),
        _ => new SolidColorBrush(Color.FromRgb(76, 175, 80))
    };
}
