loggy-neko

Crates.iologgy-neko
lib.rsloggy-neko
version0.1.2
sourcesrc
created_at2024-06-19 15:14:25.899628
updated_at2024-08-09 18:59:56.002042
descriptionloggy-neko is a thread-safe logging tool with dynamic log level configuration.
homepagehttps://github.com/durpyneko/loggy-neko
repositoryhttps://github.com/durpyneko/loggy-neko
max_upload_size
id1276979
size786,919
durpy (durpyneko)

documentation

https://github.com/durpyneko/loggy-neko

README

loggy-banner
Simple thread-safe logging tool with dynamic log level configuration.

Logging works in an hierarchy from Info > Warn > Error. If the log level is set to one of these only self and lower would log. Example:

LogLevel::Info = Info, Warn, Error
LogLevel::Warn = Warn, Error
LogLevel::Error = Error

You can also use both info/warn/error() and log(LogLevel::Level, message) for logging depending on your preference

Quickstart

use loggy_neko::prelude::*;

fn main() {
    info!("Hello World!");
}

Example usage

use loggy::{LogLevel, LOGGER};

#[derive(Debug)]
struct TestVec {
    array: Vec<String>,
}

fn main() {
    // * Standard use

    LOGGER.set_log_level(LogLevel::Error);

    LOGGER.info("Info message that wont display!");

    LOGGER.set_log_level(LogLevel::Info);

    LOGGER.info("LogLevel set to Info!");
    LOGGER.warn("Warn message!");
    LOGGER.debug("Debug message!");

    // * Or using macros

    info!("Info message using macro");

    LOGGER.set_log_level(LogLevel::Error);
    LOGGER.info("LogLevel set to Error!");

    warn!("Warn using macro that wont display!");
    error!("Error using macro");

    LOGGER.set_log_level(LogLevel::Info);
    LOGGER.info("LogLevel set to Info!");

    info!("Hello World!");

    let test_vec = TestVec {
        array: vec!["Hello".to_string(), "World!".to_string()],
    };

    info!(dbg!(format!("{:?}", test_vec).as_str()));
    warn!("Whoops!");
    debug!("Debug message via macro!");
    info!("Hello World!");
}


Outputs:

log preview screenshot

Roadmap

  • More configs: Time style, custom colors and which items to display

  • Display which function ran and at which line.

Commit count: 11

cargo fmt