grlog
A high-performance async logging library based on gorust GMP runtime.
Overview
grlog is a high-performance asynchronous logging library built on top of the gorust GMP runtime. It leverages Go-like concurrency models to provide efficient, non-blocking logging capabilities for Rust applications.
The library is designed to handle high-volume logging scenarios where traditional synchronous loggers might become bottlenecks. By utilizing gorust's lightweight goroutines and channels, grlog ensures logging doesn't block your main application threads.
Features
- Asynchronous: Non-blocking logging that won't stall your application
- High Performance: Built on gorust GMP runtime for efficient concurrency
- Flexible Configuration: Support for multiple log targets and filtering
- Environment Integration: Compatible with standard RUST_LOG environment variable
- Module-level Filtering: Configure log levels per module
- Multiple Output Targets: Console (stdout/stderr), file, and other outputs supported
- Timestamp Formatting: Automatic timestamp with millisecond precision
- Standard Compliant: Implements the popular
logcrate traits
Installation
Add this to your Cargo.toml:
[]
= "0.1.0"
= "0.4"
Usage
Basic Usage
use info;
use init;
Advanced Configuration
use ;
use ;
Logging to a File
use info;
use ;
use PathBuf;
Using Environment Variables
use init_from_env;
Configuration Options
- Targets: Choose between stdout, stderr, or file output
- Log Levels: Trace, Debug, Info, Warn, Error, or Off
- Module Filters: Set different log levels for different modules
- Buffer Size: Configure the size of the async channel buffer
Log Format
All log messages follow this format:
YYYY-MM-DD HH:MM:SS.mmm LEVEL [target] message
Example:
2023-05-14 10:30:45.123 INFO [my_app] Application started successfully
Architecture
The core of grlog is built around:
- Gorust GMP Runtime: Provides Go-like concurrency with goroutines
- Async Backend: Uses channels for non-blocking message passing
- Log Writer Interface: Pluggable writers for different output targets
- Formatter: Standardized log message formatting with timestamps
- Builder Pattern: Flexible configuration API similar to env_logger
The architecture ensures that even if the logging backend is temporarily slow, your application continues to run without blocking.
Performance
By leveraging gorust's GMP (Goroutine, Monitor, Processor) model, grlog provides:
- Extremely lightweight goroutines for log processing
- Non-blocking message passing through channels
- Minimal overhead during log emission
- Efficient batching and buffering mechanisms
- Thread-safe concurrent logging from multiple application threads
Comparison with Other Loggers
Unlike traditional Rust loggers that typically write synchronously to output streams, grlog uses an asynchronous approach that separates the act of requesting a log from the actual writing. This prevents I/O bottlenecks from affecting your application's performance.
License
Licensed under MIT license (LICENSE or http://opensource.org/licenses/MIT)
Contributing
We welcome contributions! Please feel free to submit a Pull Request. For bug reports or feature requests, open an issue on GitHub.
Changelog
v0.1.0
- Initial release
- Asynchronous logging using gorust GMP runtime
- Support for stdout, stderr and file output
- Module-specific log level filtering
- Environment variable configuration support
- Timestamped log entries with millisecond precision