Skip to main content

soma_observability/logging/
aurora.rs

1//! Aurora color palette — ANSI 256 constants for log formatting.
2//!
3//! # CUSTOMIZE: Why a separate color module?
4//!
5//! These constants are the single source of truth for color values across
6//! ALL rendering surfaces in this server:
7//!   - Console log formatting (`formatter.rs`)
8//!   - CLI output theming (if any)
9//!   - Future UI surfaces
10//!
11//! **Do not inline ANSI codes elsewhere.** Always reference `aurora::CONSTANT`.
12//! This makes palette changes a one-line edit.
13//!
14//! # CUSTOMIZE: Copy these constants EXACTLY
15//!
16//! The values below match `lab/crates/lab/src/output/theme.rs` exactly.
17//! When adapting Soma for your service, copy this file unchanged.
18//! The aurora palette is shared across the entire rmcp server family:
19//! unraid-rmcp, gotify-rmcp, unifi-rmcp, tailscale-rmcp, apprise-rmcp, and soma.
20//!
21//! # ANSI 256 vs TrueColor
22//!
23//! The log formatter uses ANSI 256 (not TrueColor) because:
24//! - ANSI 256 is supported by virtually every terminal emulator
25//! - Docker's `docker compose logs` strips TrueColor but keeps ANSI 256
26//! - The `console` crate used in lab only supports ANSI 256
27//!
28//! The RGB values shown in comments are the closest-matching TrueColor
29//! equivalents for documentation purposes only.
30
31/// Pink — used for service names, first token of log messages.
32///
33/// RGB equivalent: (255, 175, 215) — soft pink
34///
35/// Used for:
36/// - The first word of every log message (the "action verb")
37/// - The `service` structured field value
38///
39/// # Visual example (approximate)
40/// ```text
41/// HH:MM:SS  INFO  starting  bind=0.0.0.0:3000  auth=bearer
42///           ────  ────────
43///           plain  aurora::SERVICE_NAME (pink, bold)
44/// ```
45pub const SERVICE_NAME: u8 = 211;
46
47/// Bright blue — used for primary action/route/tool identifiers.
48///
49/// RGB equivalent: (41, 182, 246) — sky blue
50///
51/// Used for structured field values where the value identifies the
52/// primary action being taken:
53/// - `action=greet` → "greet" in blue
54/// - `tool=example` → "example" in blue
55/// - `route=/health` → "/health" in blue
56/// - `addr=0.0.0.0:3000` → "0.0.0.0:3000" in blue
57pub const ACCENT_PRIMARY: u8 = 39;
58
59/// Light grey — used for secondary metadata and muted text.
60///
61/// RGB equivalent: (167, 188, 201) — cool grey
62///
63/// Used for:
64/// - Subsystem names: `subsystem=mcp`
65/// - Phase names: `phase=startup`
66/// - Transport names: `transport=streamable-http`
67/// - Operation names: `operation=list`
68pub const TEXT_MUTED: u8 = 250;
69
70/// Teal — used for success states and HTTP 2xx status codes.
71///
72/// RGB equivalent: (125, 211, 199) — seafoam teal
73///
74/// Used for:
75/// - `status=200` → "200" in teal
76/// - `status=201` → "201" in teal
77/// - Any HTTP status < 300
78pub const SUCCESS: u8 = 115;
79
80/// Amber — used for warnings and HTTP 4xx status codes.
81///
82/// RGB equivalent: (198, 163, 107) — warm amber
83///
84/// Used for:
85/// - `WARN` level label (bold)
86/// - `status=404` → "404" in amber
87/// - `status=429` → "429" in amber
88/// - Any HTTP status 300–499
89/// - `kind` field on WARN/ERROR events
90pub const WARN: u8 = 180;
91
92/// Muted red — used for errors and HTTP 5xx status codes.
93///
94/// RGB equivalent: (199, 132, 144) — rose/muted red
95///
96/// Used for:
97/// - `ERROR` level label (bold)
98/// - `error=<message>` field value
99/// - `status=500` → "500" in muted red
100/// - Any HTTP status >= 500
101///
102/// # Why muted red instead of bright red?
103///
104/// Bright red (\x1b[31m) is harsh and hard to read in log streams.
105/// Aurora uses muted red (ANSI 174) for better readability while still
106/// clearly indicating error state. It's noticeable without being alarming.
107pub const ERROR: u8 = 174;
108
109#[cfg(test)]
110#[path = "aurora_tests.rs"]
111mod tests;