I made the smallest logging library on crates.io - supporting #[no_std] and multithreading!

63 points IntegralPilot

Hi fellow Rustaceans! This is my first crate so I'd love to hear feedback if you have any.

I just wanted to share a new logging and traceback library I published to crates.io, breadcrumbs. It weighs in at 8.87 KiB, the smallest I could find. It is built with #[no_std] support, and uses atomics and mutexs on the inside to ensure that it works correctly in multi-threading and concurrent environments. A (brief) example:

use breadcrumbs::{init, log, log_level, log_channel, traceback, LogLevel, LogListener, Log};

struct MyLogListner;

impl LogListener for MyLogListner {
    fn on_log(&mut self, log: Log) {
        if log.level.is_at_least(LogLevel::Warn) {
            println!("{}", log);
        }
    }
}

fn main() {
    init!(MyLogListner);

    log!("Hello, world!");
    log_level!(LogLevel::Info, "Test log message");
    log_channel!("test_channel", "Test log message");
    log!(LogLevel::Warn, "test_channel", "Test log message");

    let t = traceback!();
    println!("Fatal Error! Traceback:\

{}", t);
}

If you would like to try it out or take a peek at the code (and star if you'd like) I would be really grateful!

​

Thank you for your time!