tracing-logfmt

A logfmt formatter for tracing-subscriber that emits compact key=value structured logs

Library
Cargo
v0.3.7
47stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
29/100Needs Attention
Development Activity4
Maintenance20
Community24
Maturity56
Momentum12

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
78/100Good
Architecture78
Code Quality80
Innovation72
Learning Curve82

tracing-logfmt is a Rust crate that plugs into the tracing ecosystem to format log events in logfmt, a compact and readable structured-logging format where each line is a series of key=value pairs. It provides an event formatter for tracing-subscriber so applications already instrumented with tracing can emit logfmt output with a small amount of setup.

Values are quoted only when needed (spaces or special characters), keeping lines terse yet parseable, and an optional feature adds ANSI coloring for local development. Built and maintained by Embark Studios, it is dual licensed under MIT or Apache-2.0 in line with the standard Rust licensing model.

What You Get

  • A logfmt event formatter compatible with tracing-subscriber’s fmt layer
  • Compact key=value output with automatic, minimal quoting of values
  • A builder API for configuring which fields and metadata are emitted
  • Optional ANSI coloring via the ansi_logs feature for local development
  • Dual MIT/Apache-2.0 licensing consistent with the Rust ecosystem

Common Use Cases

  • Emitting logfmt-formatted logs from tracing-instrumented Rust services
  • Producing compact, parseable log lines for ingestion by log tooling
  • Keeping logs human readable during local development with optional colors
  • Standardizing structured log output across a fleet of Rust microservices

Under The Hood

Architecture - The crate centers on a formatter module (src/formatter.rs plus src/formatter/builder.rs) implementing tracing-subscriber’s FormatEvent trait, backed by a serializer (src/serializer.rs) that walks tracing’s fields and writes key=value pairs with logfmt-correct quoting and escaping. The builder pattern lets callers configure which span and event metadata are included. Tech Stack - Pure Rust with a small dependency surface: tracing, tracing-core, and tracing-subscriber (fmt feature) for the logging integration, the time crate for timestamp formatting, and optional nu-ansi-term behind the ansi_logs feature for coloring. Code Quality - The codebase is compact and focused, with inline unit tests in both the formatter and serializer modules, a CHANGELOG, cargo-deny configuration, a code of conduct, contributor guide, and CI, reflecting Embark Studios’ open-source practices. API Design - Usage follows the familiar tracing-subscriber pattern of installing an event formatter on the fmt layer, with a builder for customization, keeping the integration ergonomic for anyone already using tracing.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search