| Crates.io | rich-logger |
| lib.rs | rich-logger |
| version | 0.1.17 |
| created_at | 2025-01-01 07:20:16.674783+00 |
| updated_at | 2025-01-04 12:11:05.871814+00 |
| description | Rich logger implmentation in rust |
| homepage | |
| repository | https://github.com/eatmynerds/rich-logger |
| max_upload_size | |
| id | 1500644 |
| size | 32,730 |
Rich Logger is a beautiful and performant logging library for Rust, inspired by Python's rich package. It provides colorful and structured logging output, making it easier to debug and monitor applications.
To use Rich Logger in your project, add the rich-logger and log crates to your Cargo.toml:
$ cargo add log rich-logger
Or manually add the dependencies:
[dependencies]
log = "0.4"
rich-logger = "<latest-version>"
The following example demonstrates how to initialize Rich Logger and log a simple message:
use log::{info, LevelFilter};
fn main() {
rich_logger::init(LevelFilter::Debug).expect("Failed to initialize logger!");
info!("Hello, World!");
}
$ cargo add rich-logger -F async
Note: Ensures whole messages are written to the terminal even if called from multiple threads
Log highlighted data in JSON format using the json feature:
use log::{info, LevelFilter};
use serde_json::json;
fn main() {
rich_logger::init(LevelFilter::Debug).expect("Failed to initialize logger!");
info!("{}", json!({"x": 10, "y": 20}));
}
Output example:
{"x": 10, "y": 20}
Note: If you want json output to be formatted and indented you'll want to enable the pretty_json feature
Contributions are welcome! If you encounter issues or have ideas for new features, please open an issue or submit a pull request.
This project is licensed under the MIT License.