rimplog

Crates.iorimplog
lib.rsrimplog
version0.1.3
sourcesrc
created_at2024-10-18 19:33:11.003873
updated_at2024-10-19 10:30:24.463677
descriptionA simple, colorful, and easy-to-use logging library for Rust
homepage
repositoryhttps://github.com/ChisatoNishikigi73/rimplog
max_upload_size
id1414668
size13,898
Chisato73 (ChisatoNishikigi73)

documentation

https://github.com/ChisatoNishikigi73/rimplog/blob/master/README.md

README

Rimplog

A simple, colorful, and easy-to-use logging library for Rust

Rimplog means Rainbow Simple Logging

Getting Started with rimplog

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.

Dependencies

To use rimplog in your project, add the following to your Cargo.toml file:

[dependencies]
rimplog = "0.1.3"

Building the Logger

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();
}

Customizing the Logger

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 display
  • time_format: Custom time format string
  • preset: Logger preset (FULL, THREAD, SIMPLE)

Initializing the Logger

Once you've built your logger, initialize it at the start of your program:

use rimplog::init_logger;

fn main() {
    init_logger(logger);
}

Using the 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!

Commit count: 11

cargo fmt