| Crates.io | micrologger2 |
| lib.rs | micrologger2 |
| version | 0.1.0 |
| created_at | 2025-12-06 20:46:48.9079+00 |
| updated_at | 2025-12-06 20:46:48.9079+00 |
| description | A minimal logger that prints colored output based on severity level |
| homepage | |
| repository | https://github.com/userx007/uRustMicroLogger |
| max_upload_size | |
| id | 1970740 |
| size | 11,171 |
A minimal logger that prints colored output based on severity level.
println! macro - accepts format strings and arguments| Level | Color | Usage |
|---|---|---|
| ERROR | Red | Critical errors that need immediate attention |
| WARN | Yellow | Warning messages for potential issues |
| INFO | Green | General informational messages |
| DEBUG | Blue | Debug information for development |
| VERBOSE | Cyan | Detailed verbose output |
| TRACE | Gray | Fine-grained trace information |
Add to your Cargo.toml:
[dependencies]
micrologger2 = "0.1.0"
use micrologger::*;
fn main() {
log_info!("Application started");
log_error!("Failed to connect to server");
log_warn!("Low memory warning");
}
use micrologger2::*;
fn main() {
let user = "Alice";
let count = 42;
log_info!("User {} logged in", user);
log_debug!("Processing {} items", count);
log_error!("Connection failed after {} attempts", 3);
}
use micrologger2::*;
fn main() {
// Using convenience macros
log_error!("Critical error!");
log_warn!("Warning message");
log_info!("Info message");
log_debug!("Debug message");
log_verbose!("Verbose output");
log_trace!("Trace details");
// Using the generic log macro
log!(LogLevel::Info, "Custom log with level: {}", 123);
}
You can choose to color either just the log level label (default) or the entire line:
use micrologger2::*;
fn main() {
// Default: only the label is colored
log_info!("Only the [INFO] label is green");
// Color the entire line
set_color_entire_line(true);
log_info!("This entire line is green");
// Switch back to label-only coloring
set_color_entire_line(false);
log_info!("Back to label-only coloring");
}
You can test the logger locally by running the included example:
cargo run --example logtest
This will demonstrate all log levels and both coloring modes.
log!(level, format, args...) - Generic logging macro with explicit levellog_error!(format, args...) - Log an error message (red)log_warn!(format, args...) - Log a warning message (yellow)log_info!(format, args...) - Log an info message (green)log_debug!(format, args...) - Log a debug message (blue)log_verbose!(format, args...) - Log a verbose message (cyan)log_trace!(format, args...) - Log a trace message (gray)set_color_entire_line(enabled: bool) - Configure whether to color the entire line or just the labelis_color_entire_line() -> bool - Check current color mode settingLogLevel - Enum representing log severity levels: Error, Warn, Info, Debug, Verbose, TraceMIT
Contributions are welcome! Please feel free to submit issues or pull requests.