namespace Lab505.Client.Services; /// /// Single source of truth for output-log HTML rendering. /// Badges: INFO · DONE · ERR · WARN · DEV /// Columns: [ts]=75px BADGE=46px DEVICE=54px COMMAND=220px STATUS=flexible /// public static class LogFormat { // ── Severity colors (MudBlazor-aligned) ────────────────────────────── public const string CInfo = "#42a5f5"; // INFO blue public const string CWarn = "#ffa726"; // WARN orange public const string CSuccess = "#66bb6a"; // DONE green public const string CError = "#ef5350"; // ERR red public const string CDev = "#9575cd"; // DEV purple // ── Column styles ───────────────────────────────────────────────────── public const string ColTs = "display:inline-block;width:75px;color:#484848"; public const string ColDev = "display:inline-block;width:54px;color:#9e9e9e"; public const string ColCmd = "display:inline-block;width:350px;color:#c8c8c8"; public static string Ts() => DateTime.Now.ToString("HH:mm:ss"); // ── Level → (color, badge) ──────────────────────────────────────────── public static (string color, string badge) LevelBadge(string level) => level switch { "success" => (CSuccess, "DONE"), "error" => (CError, "ERR"), "warning" => (CWarn, "WARN"), "dev" => (CDev, "DEV"), "heartbeat" => (CInfo, "HB"), _ => (CInfo, "INFO"), }; // ── Level → status HTML ─────────────────────────────────────────────── public static string LevelStatus(string level) => level switch { "success" => $"✓", "error" => $"✗", "warning" => $"⚠", _ => "", }; /// 5-column line: [ts] BADGE DEVICE COMMAND STATUS │ detail public static string Line(string color, string badge, string device, string command, string status, string? detail = null) { var badgeStyle = $"display:inline-block;width:46px;color:{color};font-weight:700"; var detPart = detail != null ? $" │ {detail}" : ""; return $"[{Ts()}]" + $"{badge}" + $"{device}" + $"{command}" + $"{status}" + detPart; } /// 3-column line for DEV state changes: [ts] BADGE DEVICE message public static string LineRaw(string color, string badge, string device, string msg) { var badgeStyle = $"display:inline-block;width:46px;color:{color};font-weight:700"; return $"[{Ts()}]" + $"{badge}" + $"{device}" + $"{msg}"; } }