// ZCOLORIZER — ENGINEERING REPORT

module map · dependency footprint · test status · ccze + pygments regex→token port

>_EXECUTIVE SUMMARY

zcolorizer v0.2.2 is a single-crate Rust workspace (~3,855 lines across 10 source files) that ports ccze and the pygments regex→token idea. The pipeline is three decoupled pieces: rules tag spans of a line with semantic tokens, a theme maps each token to a style, and the engine paints the claimed spans. It ships a library (rlib + staticlib + cdylib) and a CLI binary, with the clap dependency confined to the CLI behind the default cli feature.

10
Rust source files
~3,855
Lines of Rust
47
Format modules
32
Built-in themes
108
Tests
8
Direct dependencies

~MODULE MAP

The crate is organized around the rules → theme → engine pipeline. The two module files (modules.rs + modules_modern.rs) carry the bulk of the format ports, while theme.rs holds the 32 builtin palettes. Bar widths are relative to the largest file.

SourceLinesSizeRole
src/lib.rs60
Crate root and public API; documents the rules → theme → engine pipeline.
src/rules.rs257
RuleDef/Rule: regex→token rules — named-group rules (group name is the token) and whole-match rules.
src/theme.rs517
Token→Style themes; 31 cyberpunk palettes plus ccze-classic (32 builtins), neon-sprawl default.
src/color.rs386
Color (16 named / 256-index / truecolor RGB) and Style, with ANSI SGR rendering.
src/engine.rs405
Colorizer: runs compiled rules over each line; first rule to claim a byte owns it, mirroring ccze's module-then-wordcolor flow.
src/config.rs363
TOML config — merges theme, rules and module selections; XDG config path resolution.
src/modules.rs622
Module type plus 20 classic ccze plugin ports (syslog, httpd, squid, dpkg, postfix, exim, ftp, php, ulogd…).
src/modules_modern.rs635
27 modern format modules: journald, authlog, kernel, nginx, haproxy, JSON/logfmt, postgres/mysql/redis/mongodb, docker/klog, fail2ban/ufw…
src/error.rs32
Crate Error enum (thiserror): bad-rule regex, unknown theme, config/IO errors.
src/bin/zcolorizer.rs578
CLI binary (clap): streaming stdin/file colorization, theme/module/rule listing, config dump.
10 files3,855Library (rlib + staticlib + cdylib) plus the cli-feature binary.

~ARCHITECTURE

Three independently editable pieces — change one without disturbing the others. Because color lives entirely in the theme, switching themes recolors every log without touching a single rule.

Rules

A rule is a regex whose named capture groups are tokens — one pattern can paint several fields (date, host, error). Whole-match rules use an explicit token. Fully editable in the TOML config.

Themes

A token→Style map you swap live. 31 cyberpunk palettes plus ccze-classic (32 builtins), default neon-sprawl. Colors are truecolor RGB, 256-index, or named ANSI.

Engine

Colorizer runs the compiled rules over each line; the first rule to claim a byte owns it, mirroring ccze's module-then-wordcolor flow. Streams line-buffered so tail -f / journalctl -f stay live.


~DEPENDENCY FOOTPRINT

Eight direct dependencies, all foundational and durable; clap is optional and CLI-only. All are dual-licensed MIT OR Apache-2.0, matching zcolorizer's own MIT license. The vendored ccze C source is a build-time reference only and is excluded from the published crate — the Rust port is original.

CrateVerLicenseWhy
serde1MIT / Apache-2.0Derive (de)serialization for config, themes, rules.
serde_json1MIT / Apache-2.0--themes-json emit for tooling.
toml0.8MIT / Apache-2.0Parse/emit the on-disk config and --dump-config.
regex1MIT / Apache-2.0Compiles the rule patterns that tag tokens.
thiserror2MIT / Apache-2.0Derives the crate error type.
dirs6MIT / Apache-2.0Resolves the XDG config directory.
once_cell1MIT / Apache-2.0Lazily-initialized builtin tables.
clap (optional)4MIT / Apache-2.0CLI argument parsing — only under the cli feature; the library never depends on it.

~VERIFICATION

108 tests in total: 91 unit tests embedded across the source modules plus 17 integration tests in tests/integration.rs. The integration suite drives the real colorizer through tagging assertions — verifying that syslog/httpd/squid/dpkg/postfix/exim/php/vsftpd modules paint the correct fields, that swapping a theme changes color without changing structure, that the generic word-colorizer assigns distinct tokens to good/bad word lists, that replace-mode uses only user rules, that multi-line input colorizes each line, and that config round-trips through TOML. Release profile builds with LTO and symbol stripping. Run with cargo test.

SuiteTestsScope
engine21Rule application, span claiming, line painting.
config19TOML merge, theme/rule/module selection, round-trip.
color14Named / 256-index / truecolor parsing and ANSI SGR.
theme14Builtin palettes, token→style lookup, defaults.
modules11Classic ccze plugin ports.
rules10Named-group and whole-match rule definitions.
modules_modern2Modern format module ports.
tests/integration.rs17End-to-end tagging assertions across modules + themes.
Total10891 unit + 17 integration.

~PROVENANCE

The Rust port is original; no GPL code ships in the published crate.

Upstream

Ported from ccze and the pygments regex→token idea. The vendored ccze C source is a build-time reference only and is excluded from the published crate.

Distribution

Ships as a library (rlib + staticlib + cdylib) and a CLI binary. Available on crates.io (cargo install zcolorizer) with API docs on docs.rs.

License

MIT. All eight direct dependencies are dual-licensed MIT OR Apache-2.0, matching the crate's own license.