| Crates.io | zlogger |
| lib.rs | zlogger |
| version | 0.0.1 |
| created_at | 2025-06-23 18:37:07.762052+00 |
| updated_at | 2025-06-23 18:37:07.762052+00 |
| description | A lightweight, configurable Rust logging library with color support and file rotation |
| homepage | https://github.com/liuzhen9320/zlogger |
| repository | https://github.com/liuzhen9320/zlogger |
| max_upload_size | |
| id | 1723257 |
| size | 40,392 |
A lightweight, configurable Rust logging library with color support and file rotation.
Add this to your Cargo.toml:
[dependencies]
zlogger = "0.0.1"
Basic usage:
use zlogger::{init, info, warn, error};
fn main() {
// Initialize with default settings
init();
info!("Application started");
warn!("This is a warning");
error!("Something went wrong");
}
| Variable | Description | Default | Example |
|---|---|---|---|
ZLOG_LEVEL |
Minimum log level | info |
debug |
ZLOG_OUTPUT |
Output target | console |
file, both |
ZLOG_FILE |
Log file path | app.log |
/var/log/myapp.log |
ZLOG_MAX_SIZE |
Max file size (bytes) | 10485760 (10MB) |
1048576 (1MB) |
ZLOG_MAX_FILES |
Max rotated files | 5 |
10 |
ZLOG_COLOR |
Enable colors | true |
false |
use zlogger::{init_with_config, Config, LogLevel, OutputTarget};
let config = Config::default()
.level(LogLevel::Debug)
.output(OutputTarget::Both)
.file_path("myapp.log")
.max_file_size(5 * 1024 * 1024) // 5MB
.max_files(10)
.use_colors(true);
init_with_config(config);
trace - Very detailed debug informationdebug - Debug informationinfo - General informationwarn - Warning messageserror - Error messagesWhen a log file reaches the maximum size, it's automatically rotated:
app.log â app.log.1app.log.1 â app.log.2Old files beyond the maximum count are automatically deleted.
Run the basic example:
cargo run --example basic_usage
Licensed under MIT license.
rust-lang ecosystem who have made this project possibleBuilt with âĪïļ in Rust for the community