📚 Documentation | API Reference | Quick Start
Overview
logly-rs is a high-performance, production-ready structured logging library for Rust with async support, GPU acceleration, rotation, filtering, callbacks, and comprehensive error handling.
🚀 Core Features
- 8 Log Levels: TRACE (5), DEBUG (10), INFO (20), SUCCESS (25), WARNING (30), ERROR (40), FAIL (45), CRITICAL (50)
- Custom Log Levels: Add your own levels with custom priorities and colors
- Structured Logging: JSON and custom format support
- Context Binding: Persistent and temporary context fields
- Out-of-Box Ready: Works immediately with auto-sink enabled by default
⚡ Performance & Scalability
- Async Logging: Non-blocking writes with configurable buffers
- GPU/CUDA Support: Optional GPU acceleration (compile with
--features gpu) - Thread-Safe: Lock-free operations with concurrent logging support
- Zero-Copy: Efficient memory management
- High Throughput: 13,000+ operations per second
📝 Output Management
- Multiple Sinks: Console, file, and custom outputs
- Auto-Sinks: Automatic sink initialization (enabled by default)
- Manual Sink Management: Full control over sink lifecycle
- File Rotation: Time-based (hourly, daily, weekly, monthly, yearly) and size-based rotation
- Retention Policies: Automatic cleanup of old log files
- Global Controls: Enable/disable console display and file storage globally
🔧 Filtering & Formatting
- Level Filtering: Filter by minimum log level
- Module/Function Filtering: Target specific code sections
- Custom Formatters: Template-based formatting with placeholders
- Colored Output: ANSI colors with custom color callbacks
- Custom Time Formats: YYYY-MM-DD HH:mm:ss.SSS patterns
🎯 Advanced Features
- Callbacks: Log callbacks, color callbacks, exception callbacks
- Exception Handling: Comprehensive error handling with backtraces
- Auto-Update Check: Checks for new versions automatically (enabled by default)
- Debug Mode: Detailed internal logging for troubleshooting
- Runtime Configuration: Change all settings at runtime
- Enable/Disable: Toggle logging on/off without removing sinks
Installation
Add to your Cargo.toml:
[]
= "0.0.4"
# With GPU support (experimental)
= { = "0.0.4", = ["gpu"] }
Quick Start
use *;
Performance Benchmarks
Real benchmark results from criterion (measured on your system):
| Operation | Average Time | Throughput | Notes |
|---|---|---|---|
| Basic INFO log | 75.6 μs | 13,200 ops/sec | Single message to console |
| File logging | ~150 μs | 6,600 ops/sec | With async write |
| With context | ~130 μs | 7,700 ops/sec | 2-3 bound fields |
| Concurrent (10 threads) | ~500 μs | 2,000 ops/sec | 10 threads × 100 messages |
| Multiple sinks (5) | ~200 μs | 5,000 ops/sec | Console + 4 files |
| TRACE level | ~74 μs | 13,500 ops/sec | Fastest level |
| DEBUG level | ~75 μs | 13,300 ops/sec | |
| INFO level | ~76 μs | 13,200 ops/sec | |
| WARNING level | ~75 μs | 13,300 ops/sec | |
| ERROR level | ~76 μs | 13,200 ops/sec |
Benchmarks run with criterion on Windows. Times include formatting, serialization, and I/O.
Performance Characteristics
- Memory: <1MB base overhead
- CPU: Minimal impact with async writes
- Latency: Sub-millisecond for most operations
- Scalability: Linear scaling up to 10 threads
See Performance Guide for optimization techniques.
Platform Support
- ✅ Windows: Full support (tested on Windows 11)
- ✅ Linux: Full support (Ubuntu 20.04+)
- ✅ macOS: Full support (macOS 11+)
- ⚠️ GPU: Requires CUDA toolkit (Linux/Windows only)
Advanced Usage
File Logging with Rotation
use *;
use PathBuf;
let logger = new;
let config = SinkConfig ;
logger.add_sink?;
Custom Log Levels
// Add custom level with priority between WARNING (30) and ERROR (40)
logger.add_custom_level?;
// Use custom level
logger.log_custom?;
Callbacks
// Log callback for monitoring
logger.add_log_callback;
// Custom color callback
logger.add_color_callback;
// Exception callback
logger.add_exception_callback;
Context Binding
// Bind persistent context
logger.bind;
logger.bind;
logger.info?;
// Remove binding
logger.unbind;
// Clear all bindings
logger.clear_bindings;
GPU Acceleration
let mut config = default;
config.enable_gpu = true;
config.gpu_buffer_size = 2 * 1024 * 1024; // 2MB
logger.configure;
logger.enable_gpu?;
println!;
Configuration
Basic Configuration
let mut config = default;
config.level = Debug;
config.color = true;
config.json = false;
logger.configure;
Configuration File
Create logly.toml:
[]
= "DEBUG"
= true
[]
= true
= true
= true
[]
= true
= true
= true
See Configuration Guide for all options.
Documentation
Full documentation available at: https://muhammad-fiaz.github.io/logly-rs
Getting Started
- Installation Guide - Complete installation instructions
- Quick Start - Get started in minutes
- Configuration Guide - Complete configuration reference
Feature Guides
- Log Levels - All 8 levels and custom levels
- Sinks - Multiple sinks, auto-sinks, manual management
- Rotation & Retention - File rotation (hourly to yearly)
- Configuration File - logly.toml support
- Template Formatting - Custom time formats and placeholders
- Callbacks - Log, color, and exception callbacks
- GPU Support - GPU/CUDA acceleration
- Troubleshooting - Common issues and solutions
- Performance - Optimization techniques
Project Information
- Changelog - Release history and changes
- Contributing - How to contribute
- License - MIT License
- Code of Conduct - Community guidelines
Examples
Run the examples:
# Basic usage
# Advanced features
# Complete configuration
# GPU logging (requires CUDA)
# Callbacks and custom colors
# File rotation
# Custom log levels
Testing
# Run all tests
# Run with output
# Run specific test
# Run benchmarks
Error Reporting
If you encounter any bugs or issues:
- Rust crate: https://github.com/muhammad-fiaz/logly-rs/issues
- Python package: https://github.com/muhammad-fiaz/logly/issues
Contributing
Contributions welcome! See CONTRIBUTING.md for guidelines.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Repository
Version
Current version: 0.0.4
See CHANGELOG.md for release history.
Check for updates:
if let Ok = logger.check_version
Author
muhammad-fiaz
⭐ Star the repository if you find logly-rs useful!