mtlog-tokio
Scoped logging for tokio runtimes with per-task configuration and support for log files.
Related Crates
mtlog- Use this instead for non-async, standard multi-threaded applicationsmtlog-progress- Add this for progress bars that work gracefully with mtlog
Installation
Add this to your Cargo.toml:
[]
= "0.2"
= { = "1", = ["full"] }
Features
- Scoped logging with automatic cleanup using async/await
- Task-local logger configuration
- File logging with automatic file creation and appending
- Configurable log levels and output destinations
- Designed specifically for tokio async runtimes
Usage
Basic Usage
use logger_config;
async
Multi-task Logging
use logger_config;
async
Logging to Files
Files can be used to log messages. The log file is created if it does not exist and appended to if it does. Tasks can log to different files. If no file is specified in local config, the global file is used.
use logger_config;
async
Configuration
Flush Interval
For performance optimization, file logging uses batched writes that are flushed periodically. This can be configured via the MTLOG_FLUSH_INTERVAL_MS environment variable.
Default: 100ms
Documentation
For detailed API documentation, visit docs.rs/mtlog-tokio.
License
MIT