daily-logger
A Rust logging library that provides daily file rotation and colored console output with support for order-specific logging.
Features
- Daily log rotation: Automatically creates separate log files for each day
- Order-specific logging: Support for UUID-based order logs
- Colored console output: Different colors for different log levels
- Dual output: Simultaneous logging to console and files with separate level controls
- File caching: Efficient file handle management with LRU cache
- Thread-safe: Built with concurrency in mind
Installation
Add this to your Cargo.toml:
[]
= "0.1.0"
Usage
Basic Setup
use init_logger;
use ;
Order-Specific Logging
The logger supports special UUID-based logging for tracking specific orders or transactions:
use info;
Log Output Formats
Console Output
Console logs are colored by level and include timestamps:
2024-01-15T10:30:45+00:00-INFO|[orders]<123e4567>:Order processing started
File Output
Files are created in the base directory:
- Daily logs:
log_2024_1_15.log(contains all logs for the day) - Order logs:
order_123e4567-e89b-12d3-a456-426614174000.log(UUID-specific logs)
Log Levels
The library supports standard log levels with color coding:
| Level | Color | Description |
|---|---|---|
| ERROR | Red | Error conditions |
| WARN | Yellow | Warning conditions |
| INFO | Green | Informational messages |
| DEBUG | Blue | Debug information |
| TRACE | Gray | Trace information |
Configuration
Level Filtering
You can set different log levels for console and file output:
init_logger;
File Management
The logger uses an internal file cache (max 32 files) with LRU eviction to efficiently manage file handles. Log directories are created automatically if they don't exist.
Dependencies
chrono- Date and time handlinglog- Logging facadeonce_cell- Thread-safe lazy initializationdashmap- Concurrent hash map (if used in your implementation)
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.