Expand description
§zcolorizer
A real-time log colorizer — a Rust port of ccze and the pygments regex→token idea — with fully customizable rules and swappable themes.
The pipeline is three decoupled pieces:
rules— regexes that tag spans of a line with a semantic token (date,error,host, …). Named capture groups make one regex paint several fields. Rules live in the config, so users own them entirely.theme— a named map from token →color::Style. The active theme decides what each token looks like; swapping it recolors everything (the “pick the theme from zgui” flow). The flagship istheme::cyberpunk.engine::Colorizer— runs the compiled rules over each line and paints the claimed spans with the theme.
config::Config ties them together from a TOML file.
§Quick start
use zcolorizer::Colorizer;
let cz = Colorizer::from_config(&zcolorizer::config::Config::default(), None).unwrap();
let painted = cz.colorize_line("Jun 27 14:03:11 host sshd[1234]: ERROR bad login");
assert!(painted.contains("\x1b["));Re-exports§
pub use color::Color;pub use color::Style;pub use config::Config;pub use engine::Colorizer;pub use error::Error;pub use error::Result;pub use theme::Theme;
Modules§
- color
- Color and text-style model plus ANSI SGR rendering.
- config
- Configuration: the on-disk TOML that makes rules and themes fully customizable.
- engine
- The colorization engine: turn a plain line into an ANSI-colored line by running the compiled rules and painting the spans they claim with the active theme’s styles.
- error
- Crate error type.
- modules
- Format-specific colorizers — the port of ccze’s plugins (
mod_*.c). - modules_
modern - Modern log-format modules — the formats you actually tail today that ccze (2003) never covered: systemd/journald, sshd/auth, kernel, nginx, JSON & logfmt, Postgres/MySQL/Redis/Mongo, Docker/Kubernetes, app frameworks, and common network services. Each was researched against real on-disk lines.
- rules
- Rules: regex patterns that tag spans of a line with a semantic token.
- theme
- Themes: a named mapping from semantic token →
Style.