LogFlow
A beautiful, customizable, and performant logging library for Rust with perfect terminal UI.
LogFlow is designed to address the common pain points in Rust logging by providing:
- Beautiful terminal output with rich colors and formatting
- Zero-config defaults with extensive customization options
- High performance with minimal overhead
- Native async support with proper context propagation
- Hierarchical/nested logging with visual indentation
- Thread-safe by design
- Multiple output formats (JSON, pretty, compact, custom)
- Real-time filtering and log level management
Quick Start
Add LogFlow to your Cargo.toml:
[]
= "0.1.0"
# For async support
= { = "0.1.0", = ["async"] }
Basic Usage
use *;
Nested Logging
use *;
Structured Logging with Fields
use *;
Async Logging
use *;
async
Features
Beautiful Terminal Output
LogFlow provides multiple formatting options:
- Pretty Mode: Beautiful colors and clear hierarchy
- Compact Mode: Minimal output for production environments
- JSON Mode: Structured output for log aggregation
- Development Mode: All debugging information included
Hierarchical Logging
Create nested log scopes that automatically indent and track context:
let scope1 = logger.begin_scope;
scope1.info?;
// Inner scope ends
scope1.info?;
Structured Fields
Add structured data to your logs:
logger
.with_field
.with_field
.with_field
.info?;
Subtitle Support
LogFlow supports subtitles for better log categorization and visual organization:
use *;
Subtitles appear as colored, bold labels that help categorize and organize your logs visually.
High Performance
- Efficient formatting with minimal allocations
- Optional buffering for high-throughput scenarios
- Background flushing for async applications
- Zero-cost abstractions where possible
Extensive Customization
let logger = new
.with_level
.with_colors
.with_timestamps
.with_module
.with_file_line
.with_bold_subtitles
.build?;
Configuration Options
Log Levels
Trace- Very detailed diagnostic informationDebug- Diagnostic information for debuggingInfo- General information about program executionWarn- Warning messages for potentially harmful situationsError- Error messages for error conditionsFatal- Critical errors that may cause termination
Output Formats
- Pretty: Colorful format perfect for development
- Compact: Minimal format ideal for production
- JSON: Structured format for log aggregation systems
- Custom: Implement your own formatting logic
Output Destinations
- Stdout: Standard output (default)
- Stderr: Standard error
- File: Write to a specific file
- Buffer: Write to an in-memory buffer
- Custom: Implement your own output writer
Examples
The examples/ directory contains comprehensive demonstrations:
basic_usage.rs- Getting started with LogFlownested_logging.rs- Hierarchical logging patternsfield_logging.rs- Structured logging with fieldsasync_logging.rs- Async logging patternscustom_formatting.rs- Customization optionsperformance_demo.rs- Performance benchmarks
Run examples with:
LogFlow - Where logs flow beautifully
