#debug #log

debug-log

Dead simple log utils for debug. Filter and group logs.

5 releases

Uses new Rust 2021

0.1.4 Nov 28, 2022
0.1.3 Nov 28, 2022
0.1.2 Nov 28, 2022
0.1.1 Nov 18, 2022
0.1.0 Nov 18, 2022

#186 in Debugging

Download history 61/week @ 2022-11-17 76/week @ 2022-11-24 23/week @ 2022-12-01

160 downloads per month

MIT license

10KB
159 lines

debug-log

Documentation

Dead simple log utils for debug in Rust.

  • 🦀 Enabled only in debug mode when DEBUG environment variable is set
  • 🔊 Only perform log in files whose paths match DEBUG="filename". Match all by using DEBUG="", or DEBUG="*"
  • 📦 Group output with debug_group

The output log is super easy to read on VS Code with sticky scroll enabled.

Example

use debug_log::{debug_dbg, debug_log, group, group_end};
fn main() {
    group!("A Group");
    {
        group!("Sub A Group");
        let arr: Vec<_> = (0..3).collect();
        debug_dbg!(&arr);
        {
            group!("Sub Sub A Group");
            debug_dbg!(&arr);
            group_end!();
        }
        debug_log!("Hi");
        debug_dbg!(&arr);
        group_end!();
    }

    {
        group!("B Group");
        debug_log!("END");
        group_end!();
    }
    group_end!();
}

Run with DEBUG=* cargo run

Output

A Group {
    Sub A Group {
        [src/lib.rs:144] &arr = [
            0,
            1,
            2,
        ]
        Sub Sub A Group {
            [src/lib.rs:147] &arr = [
                0,
                1,
                2,
            ]
        }
        [src/lib.rs:150] Hi
        [src/lib.rs:151] &arr = [
            0,
            1,
            2,
        ]
    }
    B Group {
        [src/lib.rs:157] END
    }
}

No runtime deps