Crates.io | log4you |
lib.rs | log4you |
version | 0.1.4 |
source | src |
created_at | 2025-04-16 08:17:07.661713+00 |
updated_at | 2025-05-31 13:23:06.715214+00 |
description | Structured logging for Rust with dynamic UUID log IDs, built on log4rs. |
homepage | |
repository | https://github.com/jerry-maheswara-github/log4you |
max_upload_size | |
id | 1636125 |
size | 58,150 |
Structured logging for Rust with dynamic UUID log IDs, built on log4rs.
log4you is a lightweight logging crate, designed for applications that need consistent, structured logging with unique log identifiers (UUIDs). It allows simple, efficient, and consistent logging with unique log IDs for each request.
log4rs
, configure logging dynamically with YAML configuration files, compatible with the standard Rust log
facadelog_id
(UUID v7) per log entry using Uuid::now_v7().simple() via log_id!
macrolog_info!
, log_error!
, etc.Perfect for microservices, APIs, and any system where traceability and clean logs matter.
See the log4rs
configuration documentation for more details.
appenders:
stdout:
kind: console
encoder:
pattern: "[{d(%Y-%m-%dT%H:%M:%S%.6f)} {h({l})} {f}:{L}] - {m}{n}"
log4you:
kind: rolling_file
path: "logs/log4you.log"
policy:
kind: compound
trigger:
kind: size
limit: 100MB
roller:
kind: fixed_window
pattern: "logs/log4you-{}.log"
count: 5
encoder:
pattern: "[{d(%Y-%m-%dT%H:%M:%S%.6f)} {h({l})} {f}:{L}] - {m}{n}"
root:
level: info
appenders:
- stdout
loggers:
log4you:
level: debug
appenders:
- log4you
use log4you::{logger::Logger, log_id, log_info, log_info_with_id};
fn main() {
let logid = log_id!();
// Initialize the logger with a log_id, a path to the YAML config, and the service name
Logger::init(&logid, Some("config/log4you.yaml"), Some("log4you"));
// Log an info message, logid will be generated automatically
log_info!("Service started");
// Log an info message, logid is defined by yourself
let custom_log_id = log_id!();
log_info_with_id!(custom_log_id, "This log uses custom log_id");
}
Licensed under:
Created and maintained by Jerry Maheswara
Feel free to reach out for suggestions, issues, or improvements!
This project is built with โค๏ธ using Rust โ a systems programming language that is safe, fast, and concurrent. Rust is the perfect choice for building reliable and efficient applications.
Pull requests, issues, and feedback are welcome!
If you find this crate useful, give it a โญ and share it with others in the Rust community.