rust.missing_structured_logging
Observability
Medium
Detects unstructured string logging instead of structured logs with fields.
Why It Matters
Section titled “Why It Matters”Unstructured logs:
- Hard to query — Can’t filter by field values
- No aggregation — Can’t count by error type
- Poor metrics — Harder to build dashboards
Example
Section titled “Example”// ❌ Before (unstructured logging)info!("User {} logged in from {}", user_id, ip_address);error!("Failed to process order {}: {}", order_id, err);// ✅ After (structured logging with tracing)use tracing::{info, error};
info!(user_id = %user_id, ip = %ip_address, "User logged in");error!(order_id = %order_id, error = ?err, "Failed to process order");What Unfault Detects
Section titled “What Unfault Detects”- Format strings with interpolated values
- Missing structured fields in log macros
- Debug prints in production paths
Auto-Fix
Section titled “Auto-Fix”Unfault can convert to structured tracing macros with named fields.