Expand description
§tpt-logfmt-parse
Zero-copy, high-performance logfmt parser for Rust. No dependencies.
Logfmt is the key=value structured logging format used by Heroku, Datadog agents, and many Go services.
§Features
- Zero-copy iterator — yields
(&str, &str)slices directly into the input string - Owned convenience API —
parse_to_map()returnsHashMap<String, String>with escape sequences resolved - No dependencies — pure Rust, no
regex, no allocations in the iterator path - Handles quoted strings,
\"/\\/\n/\tescape sequences, and bare keys (no=)
§Usage
§Zero-copy iterator
use tpt_logfmt_parse::LogfmtParser;
let input = r#"level=info msg="hello world" latency=42ms"#;
for pair in LogfmtParser::new(input) {
let (key, value) = pair.unwrap();
println!("{key} = {value}");
}§Owned HashMap
use tpt_logfmt_parse::parse_to_map;
let map = parse_to_map(r#"level=error msg="disk full" retries=3"#).unwrap();
println!("{}", map["msg"]); // disk full§License
Licensed under either of Apache License 2.0 or MIT at your option.
Zero-copy logfmt parser. See LogfmtParser for the streaming iterator API
and parse_to_map for the convenience owned-map API.
Structs§
- Logfmt
Error - An error produced during logfmt parsing.
- Logfmt
Parser - Zero-copy streaming logfmt parser.
Functions§
- parse_
to_ map - Parse a logfmt string into an owned
HashMap<String, String>.