Expand description
§
tailspin is a log file highlighter. This crate exposes the Highlighter type,
allowing you to programmatically apply the same pattern-driven highlighting used by the CLI.
In order to configure the highlighter, use the HighlighterBuilder. Otherwise, use
Highlighter::default() for reasonable defaults.
§Dependency usage
When using tailspin as a library, disable default features to avoid pulling in
CLI-specific dependencies like tokio, clap, and rayon:
[dependencies]
tailspin = { version = "6.0", default-features = false }§Example
use tailspin::config::*;
use tailspin::Highlighter;
use tailspin::style::{Color, Style};
let highlighter = Highlighter::builder()
.with_number_highlighter(NumberConfig {
style: Style {
fg: Some(Color::Cyan),
..Style::default()
},
})
.with_quote_highlighter(QuoteConfig {
quote_token: b'"',
style: Style {
fg: Some(Color::Yellow),
..Style::default()
},
})
.with_uuid_highlighter(UuidConfig::default())
.build()
.expect("Failed to build highlighter");
let input = "Hello 42 world";
let output = highlighter.apply(input);
// "\x1b[36m" = ANSI cyan start, "\x1b[0m" = reset
assert_eq!(output, "Hello \x1b[36m42\x1b[0m world");Modules§
- config
- Configuration support for custom highlighting themes and regex rules.
- style
- ANSI style and color definitions for highlighted output.
Structs§
- Highlighter
- A pattern-based log highlighter.
- Highlighter
Builder - Builder for configuring a
Highlighter.