Crates.io | rimplog |
lib.rs | rimplog |
version | 0.1.3 |
source | src |
created_at | 2024-10-18 19:33:11.003873 |
updated_at | 2024-10-19 10:30:24.463677 |
description | A simple, colorful, and easy-to-use logging library for Rust |
homepage | |
repository | https://github.com/ChisatoNishikigi73/rimplog |
max_upload_size | |
id | 1414668 |
size | 13,898 |
A simple, colorful, and easy-to-use logging library for Rust
Rimplog means Rainbow Simple Logging
rimplog is a simple, colorful, and easy-to-use logging library for Rust. This guide will help you get started with rimplog in your Rust projects.
To use rimplog in your project, add the following to your Cargo.toml
file:
[dependencies]
rimplog = "0.1.3"
rimplog uses a builder pattern to configure the logger. Here's how to create a custom logger:
use rimplog::{LoggerBuilder, LoggerPreset};
pub fn main() {
let logger = LoggerBuilder {
level: "info",
only_project_logs: true,
path_depth: 1,
time_format: "%Y-%m-%d %H:%M:%S".to_string(),
preset: LoggerPreset::FULL,
};
}
If you're happy with the default settings, you can simply use:
use rimplog::LoggerBuilder;
pub fn main() {
let logger = LoggerBuilder::default();
}
You can customize the following options:
level
: Log level (off
, error
, warn
, info
, debug
, trace
)only_project_logs
: Whether to show only project logs (true
/false
)path_depth
: Depth of file path to displaytime_format
: Custom time format stringpreset
: Logger preset (FULL
, THREAD
, SIMPLE
)Once you've built your logger, initialize it at the start of your program:
use rimplog::init_logger;
fn main() {
init_logger(logger);
}
After initialization, you can use the logging macros throughout your code:
use rimplog::{info, error, warn, debug, trace};
fn some_function() {
info!("This is an info log");
error!("This is an error log");
warn!("This is a warning log");
debug!("This is a debug log");
trace!("This is a trace log");
loggger::info!("This is an info log")
}
For logs without automatic newlines, use the underscore versions:
use rimplog::{_info};
fn another_function() {
_info!("installing: ");
println!("success");
}
That's it! You're now ready to use rimplog in your Rust projects. Enjoy colorful and customizable logging!